20 views

Uploaded by Koay HV

Tutorial on Python

Tutorial on Python

Attribution Non-Commercial (BY-NC)

- San Foundry c Programs
- Python Programming
- MCA 101: Information Technology Unit – I Business and Information
- New Text Document 1
- C Good Questions
- 01 Intro
- GE6263 SET1
- C Program to Reverse an Array Using Recursion.pdf
- Python Handouts Virtualenv
- MISRA C 2012 - Technical Corrigendum 1 Technical Clarification of MISRA C 2012
- soalan it
- c Programs
- C Programming - Pointers
- Computer 1718
- SCJP Parcial 2013
- Informative Powerpoint
- Compute Bs
- anand's java
- Vernalis Tech Qn 5
- practicepaper-capecomputerscienceunit1paper1-140114225056-phpapp01

You are on page 1of 4

print(type(this is a chunk of text) a = 3 b = a c = a print + 5 * a a - 1 * b (c) 440 10 1 this is a chunk of text <type int> <type str>

a = -6 b = a * a a - 1 c = a * b if(a<0): print(a<0) print(c) else: print(a is not less than 0) print(c-a) print(we are done with the program) Lesson 2: Binary numbers Base 10 Digits: {0,1,2,3,4,5,6,7,8,9} Hundreds, tens, ones E.g. 1,2,3,4,5,6,7,8,9,10,11

Base 2 (0,1) Digits: {0,1} Eights, Fours, Twos, Ones E.g. 0,1,10,11 Ex: 1010 (Base 2) = 10 (Base 10) (1-eight + 0-fours + 1-twos + 0-ones)

Lesson 3: List of Python >>> a = [1, 2, -1, 9, 11] >>> print a [1,2,-7,9,11] >>> a[1]=sals string >>> print a [1, sals string, -7, 9, 11] >>> b= a >>> print b [1, sals string, -7, 9, 11] >>>c = a[:] >>> print c [1, sals string, -7, 9, 11]

>>>b[0]=0 >>> print b [0, sals string, -7, 9, 11] >>> print a [0, sals string, -7, 9, 11] >>> print c [1, sals string, -7, 9, 11] >>>a [0, sals string, -7, 9, 11] >>> a.append(new element) >>> a [0, sals string, -7, 9, 11], new element] >>>b [0, sals string, -7, 9, 11], new element] >>>c [1, sals string, -7, 9, 11] Lesson 4: For Loops in Python >>> [0, >>> [0, >>> [1, >>> [0, >>> [3, range(6) 1, 2, 3, 4, 5] range(7) 1, 2, 3, 4, 5, 6] range(1, 7) #include, up to but not include 2, 3, 4, 5, 6] range(0, 8, 2) 2, 4, 6] range(3, 31, 3) 6, 9, 12, 15, 18, 21, 24, 27, 30] 0 1 2 3 4 0 1 3 4 10 15 21 28 36 45

Lesson 5: While Loops in Python # This while loop calculates the sum of 0 through 9 (including 9) and places # it in the variable sum sum = 0 i = 0 while i<10: sum = sum + i 0 1 3 4 10 15 21

print sum i = i + 1 #for I in range(10): # sum = sum + i # print sum Lesson 6: Fun with strings a = My first test string b = Another test string that I have defined c = This is Sals string d = My favourite word is asparagus, what is yours? math_string = 3+4*2 expression_string = a+ +b+ tiger

28 36 45

>>> a My first test string >>> len(a) 20 >>> len(math_string) 5 >>> a_with_b = a+b >>> a_with_b Myfirst test stringAnother test string that I have defined >>> b_with_a = b+a >>> b_with_a Another test string >>> math_string+expression_string 3+4*2a++b+ tiger >>> b.split( ) [Another, test, string, that, I, have, defined] >>> b.split(t) [Ano, her, es, s, ring, ha, I have defined] >>> math_string.find(*) 3 >>> math_string.find(3) 0 >>> c.replace(i, o) Thos os Sals strong >>> c = c.replace(i, o) >>> c Thos os Sals strong >>> math_string 3+4*2 >>> eval(math_string) 11 >>> eval(math_string+ 1) 3+4*21 87 >>> eval(expression_string) My first test string Another test string that I have defined tiger

Lesson 7: Writing a Simple Factorial Program using Python 2 number = input(Enter a non-negative integer to take the factorial of: ) product = 1 for i in range(number): product = product * (i+1) print(product) >>>3 6 >>>10 3628800

Lesson 8: Stepping Through the Factorial Program number = input(Enter a non-negative integer to take the factorial of: ) product = 1 for i in range(number): product = product * (i+1) print(product)

- San Foundry c ProgramsUploaded bysiddu
- Python ProgrammingUploaded byCharnelle Smoak
- MCA 101: Information Technology Unit – I Business and InformationUploaded byGosukondaBalavenkataAnanthBharadwaj
- New Text Document 1Uploaded bySathya Kosana
- C Good QuestionsUploaded byVineet_Goyal9
- GE6263 SET1Uploaded byAnonymous zPhPiS3a
- C Program to Reverse an Array Using Recursion.pdfUploaded byafnaanqurreshi
- Python Handouts VirtualenvUploaded byLuke Constable
- 01 IntroUploaded bydarwinvargas2011
- MISRA C 2012 - Technical Corrigendum 1 Technical Clarification of MISRA C 2012Uploaded byGunzungKim
- soalan itUploaded byachai12
- c ProgramsUploaded byKarthik Kartz
- C Programming - PointersUploaded byvisheshg
- Computer 1718Uploaded byMoorthy Gaccs
- SCJP Parcial 2013Uploaded byvimale8
- Informative PowerpointUploaded byericperalli
- Compute BsUploaded byAshish Bharadwaj
- anand's javaUploaded byAnand Dhanalakota
- Vernalis Tech Qn 5Uploaded bypriyajenat
- practicepaper-capecomputerscienceunit1paper1-140114225056-phpapp01Uploaded byDeepak Dinesh
- PEGACSA_v6.2Uploaded bysatish s
- 4Uploaded bypostscript
- 10.1109@TAI.2003.1250218Uploaded byZainal Arifin
- 07 C ProgrammingUploaded bySubramanian Venkatesan
- Exercícios - Creating and Using ArraysUploaded byJackson Angell
- DAS Python vs GoUploaded byaaa
- CPET190_Lect5Uploaded byLayl Zan
- Extra ExercisesUploaded byRui Pedro Moreira
- Curs_C(Cork).docUploaded byDaman Preet Singh Khurl
- SysTypes V3x EUploaded bymuhamad.badar9285

- IoT Robotics Game_MRCUploaded byKoay HV
- KIE3004 Chapter 2 Plane WavesUploaded byKoay HV
- Applied EMUploaded byKoay HV
- 96643811-Chapter-06-Hw.docUploaded byKoay HV
- Territory Defence Game_MRC.pdfUploaded byKoay HV
- Bernard ChandranUploaded byKoay HV
- Bode PlotUploaded byTharindu Chathuranga
- Semilog Paper for Bode PlotsUploaded byKoay HV
- Samsung Malaysia NewsroomUploaded byKoay HV
- Ocv With PyqtUploaded byKoay HV
- Tutorial 1 Cost ConceptUploaded byKoay HV
- Tutorial 2 AnswerUploaded byKoay HV

- Interview Questions - Anurag Barua - 142 PgsUploaded byVijay Chandra
- Matrix Compositing BrochureUploaded byCristianJiménez
- Excel 10 Automatic GradingUploaded byMd Yusof
- Expert Office 365 Notes From the FieldUploaded byYohanna Monsalvez
- Servicing HP Enterprise NetworkingUploaded byMarianela Marin
- Topic 10 Factor Analysis and ReliabilityUploaded bysumilah
- Public Webinar Tsunami 8200 LaunchUploaded byproximwireless
- Selenium.xlsxUploaded byVaralakshmi Suresh
- Global positioning system(GPS)Uploaded bymanishachoudhary14
- SPE 71430 SimulationUploaded byJoy Faruz
- Isharediskhelp EnUploaded byfrancis del rosario
- Idea NetSetter E303_E303D_E303Ds-1 Unlock Solution - Everything Unlock HereUploaded byKrishna Chaitanya
- Toronto Presentations Aug 29pmUploaded by560107
- Target User Manual EngUploaded byBorne
- decap.pdfUploaded byShivalika Singh
- (Immigration and Asylum Law and Policy in Europe 15) Evelien Brouwer-Digital Borders and Real Rights_ Effective Remedies for Third-Country Nationals in the Schengen Information System-Martinus NijhoffUploaded byinaboss
- The Moldovan Medical Journal Vol 61 MaiUploaded byBooker Dewitt
- 7sdsavk Manual Pixit a3 v042001 EnUploaded byRitesh Jaiswal
- Question BankUploaded byani07l
- ch10Uploaded byjoyabyss
- The Fourier TransformUploaded bymahamd saied
- Introduction NS2 SimulatorUploaded byalagiri
- 1771-p7Uploaded byDwi Ananda Ramadhany
- 01_IntroductionWCETdffdfUploaded byVojo Voki
- How to BI Java SDK WebDynpro AppUploaded byJoey Reyes
- u230uUploaded byErwin Ademir Solano
- dm09011b0281765f85Uploaded byJohnny_Besugo
- DOTNET Programming Concepts Difference FAQs-3Uploaded byUmar Ali
- Pega GlossaryUploaded byGaurav Lakshkar
- TSX17 20 SelectionUploaded byPariapaza Enrique Luis