Python Programming: An Introduction to Computer Science
PythonProgramming: AnIntroductiontoComputerScience JohnM.Zelle,Ph.D. Version1.0rc Fall 2002 ...
Copyrightc 2002 byJohnM.Zelle Allrightsreserved.Nopartofthispublicationmaybereproduced,storedin a retrieval system,ortransmitte ...
Contents ...
...
...
...
1 ComputersandPrograms 1.1 TheUniversalMachine. 1.2 ProgramPower 1.3 Whatis ComputerScience?. 1.4 HardwareBasics 1.5 Programmin ...
vi CONTENTS ...
Chapter 1 Computers and Programs Almosteveryonehasuseda computeratonetimeoranother. Perhapsyouhave playedcomputergamesor useda c ...
2 CHAPTER1. COMPUTERSANDPROGRAMS 1.2 ProgramPower Youhave alreadylearnedanimportantlessonofcomputing:Software(programs)rulestheh ...
1.4.HARDWAREBASICS 3 Input Devices CPU Secondary Memory Main Memory Output Devices Figure1.1:FunctionalView ofa Computer. analys ...
4 CHAPTER1. COMPUTERSANDPROGRAMS 1.5 ProgrammingLanguages Rememberthata programis justa sequenceofinstructionstellinga computerw ...
1.6.THEMAGICOFPYTHON 5 (Program) Compiler Machine Code Running Inputs Outputs Source Code Program Figure1.2:Compilinga High-Leve ...
6 CHAPTER1. COMPUTERSANDPROGRAMS print "Hello, World" Hello, World print 2 + 3 5 print "2 + 3 =", 2 + 3 2 + 3 = 5 HereI ha ...
1.6.THEMAGICOFPYTHON 7 Canyouseewhatis happeninghere?Whenweusegreetwecansenddifferentnamestocustomizethe result.We willdiscusspa ...
8 CHAPTER1. COMPUTERSANDPROGRAMS Typingthefirstlineimport chaostellsthePythoninterpretertoloadthechaosmodulefromthefile chaos.py ...
1.7.INSIDEA PYTHONPROGRAM 9 File: chaos.py A simple programillustrating chaotic behavior. print "This programillustrates a chaot ...
10 CHAPTER1. COMPUTERSANDPROGRAMS print x x = 3.9 x (1 - x) print x Obviouslyusingtheloopinsteadsavestheprogrammera lotoftroub ...
1.9.EXERCISES 11 0.166187 0. 0.540418 0. 0.968629 0. 0.118509 0. Withverysimilarstartingvalues,theoutputsstaysimilarfora fewiter ...
12 CHAPTER1. COMPUTERSANDPROGRAMS x = 2.0 * x * (1 - x) Runtheprogramforvariousinputvaluesandcomparetheresultstothoseobtainedfro ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf