Example: bachelor of science

COMP150: Practical Programming (in Python)

COMP150: Practical Programming (in Python) Jeffrey ElknerAllen B. DowneyChris MeyersBrendan McCaneIain HewsonNick MeekJune 22, 2009iiContents1 The way of the Python Programming language .. is a program? .. is debugging? .. debugging .. and natural languages .. first program .. COMP150 lab .. OSX desktop .. dock .. Finder window .. home directory .. help .. Coursework files .. Terms requirements .. Laboratory exercises ..142 Variables, expressions and and types .. names and keywords .. expressions .. and operands .. modulus operator .. of operations .. on strings .. Glossary .. Laboratory exercises ..263 Python built-ins (batteries included) calls .. conversion .. things .. types.

If you aren’t interested in becoming a computer scientist, but just want to gain some programming skills, then this is the perfect paper for you. In this paper we are going to focus on practical programming skills suitable for solving smallish programming problems. Problems that you will often encounter if you use a computer regularly.

Tags:

  Programming, Practical, Practical programming

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of COMP150: Practical Programming (in Python)

1 COMP150: Practical Programming (in Python) Jeffrey ElknerAllen B. DowneyChris MeyersBrendan McCaneIain HewsonNick MeekJune 22, 2009iiContents1 The way of the Python Programming language .. is a program? .. is debugging? .. debugging .. and natural languages .. first program .. COMP150 lab .. OSX desktop .. dock .. Finder window .. home directory .. help .. Coursework files .. Terms requirements .. Laboratory exercises ..142 Variables, expressions and and types .. names and keywords .. expressions .. and operands .. modulus operator .. of operations .. on strings .. Glossary .. Laboratory exercises ..263 Python built-ins (batteries included) calls .. conversion .. things .. types.

2 And lists .. exercises ..354 Functions: part expressions .. definitions and use .. of execution .. and arguments .. composition .. exercises ..445 Functions: part and parameters are local .. diagrams .. exercises ..496 values and expressions .. operators .. execution .. execution .. conditionals .. conditionals .. and type conversion .. exercises ..587 Fruitful return statement .. values .. development .. functions .. function type .. exercises ..708 Test driven , files and theimportstatement .. with style .. quoted strings .. testing withdoctest.. development demonstrated .. exercises ..769 Files and .. things from a file .. modules .. and the dot operator.

3 Test ..8610 Iteration: part Multiple assignment .. Updating variables .. Thewhilestatement .. Tracing a program .. Counting digits .. Abbreviated assignment .. Tables .. Glossary .. Laboratory exercises ..9711 Iteration: part Two-dimensional tables .. Encapsulation and generalization .. More encapsulation .. Local variables .. More generalization .. Functions .. Newton s method .. Algorithms .. Glossary .. exercises .. 10412 In-class test10713 Graphical user interface Event driven Programming .. TkInter introduction .. Introducing callbacks .. User input .. Mini-case study .. Glossary .. Laboratory exercises .. 11714 Case study: Graphics.

4 Moving the ball .. Adding randomness .. Glossary .. Laboratory exercises .. 12415 Case study: Catch Keyboard input .. Checking for collisions .. Keeping score .. Glossary .. Laboratory exercises .. Optional extension project: .. 13216 Strings part A compound data type .. Length .. Traversal and theforloop .. String slices .. String comparison .. Strings are immutable .. Theinoperator .. A find function .. Looping and counting .. parameters .. exercises .. 14017 Strings part .. Character classification .. String formatting .. Glossary .. Laboratory exercises .. 14818 Lists part List values.

5 Accessing elements .. List length .. List membership .. List operations .. List slices .. The range function .. Lists are mutable .. List deletion .. and values .. lists .. exercises .. 15919 Lists part Lists and for loops .. List parameters .. Pure functions and modifiers .. Which is better? .. Nested lists .. Matrices .. Strings and lists .. Glossary .. Laboratory exercises .. 16620 Tuples and mutability .. Tuple assignment .. Tuples as return values .. Why tuples? .. When should you use tuples? .. Sets .. Glossary .. Laboratory Test .. 17121 Dictionary operations.

6 Dictionary methods .. Aliasing and copying .. Sparse matrices .. Counting letters .. Glossary .. Laboratory exercises .. 18222 System The sys module and argv .. Theosandglobmodule .. A mini-case study .. ImageMagick .. Scripting ImageMagick .. Glossary .. Laboratory exercises .. 191viii23 Classes and Object-oriented Programming .. User-defined compound types .. TheinitMethod andself.. Attributes .. Methods .. Sameness .. Rectangles .. Instances as return values .. Objects are mutable .. exercises .. 20224 Case study Program Design .. The Initial Program .. Opening a File .. Saving to a File.

7 Encrypting the Contents .. Putting it All Together .. Glossary .. Laboratory Exercises .. 21425 The last Stuff we haven t covered .. What you can expect from COMP160 and Computer Science .. 215 Extra Extension Exercises from Part 1217 GNU Free Documentation License2211. APPLICABILITY AND DEFINITIONS .. 2212. VERBATIM COPYING .. 2223. COPYING IN QUANTITY .. 2234. MODIFICATIONS .. 2235. COMBINING DOCUMENTS .. 2246. COLLECTIONS OF DOCUMENTS .. 2257. AGGREGATION WITH INDEPENDENT WORKS .. 2258. TRANSLATION .. 2259. TERMINATION .. 225ix10. FUTURE REVISIONS OF THIS LICENSE .. 226 ADDENDUM: How to use this License for your documents .. 226xLecture 1 The way of the programThe goal of this paper is twofold: to teach you how to program in Python; and to teach you to think likeacomputer scientist.

8 It is almost impossible to become a competent programmer without also learninghow to think like a computer scientist. This way of thinking combines some of the best features of math-ematics, engineering, and natural science. Like mathematicians, computer scientists use formal languagesto denote ideas (specifically computations). Like engineers, they design things, assembling componentsinto systems and evaluating trade-offs among alternatives. Like scientists, they observe the behaviour ofcomplex systems, form hypotheses, and test you aren t interested in becoming a computer scientist, but just want to gain some Programming skills,then this is the perfect paper for you. In this paper we are going to focus on Practical Programming skillssuitable for solving smallish Programming problems.

9 Problems that you will often encounter if you use acomputer single most important skill for a computer scientist isproblem solving. Problem solving means theability to formulate problems, think creatively about solutions, and express a solution clearly and accu-rately. As it turns out, the process of learning to program is an excellent opportunity to practice problem-solving skills. That s why this chapter is called, The way of the program. On one level, you will be learning to program, a useful skill by itself. On another level, you will useprogramming as a means to an end. As we go along, that end will become The Python Programming languageThe Programming language you will be learning is Python. Python is an example of ahigh-level language;other high-level languages you might have heard of are C++, PHP, and you might infer from the name high-level language, there are alsolow-level languages, sometimesreferred to as machine languages or assembly languages.

10 Loosely speaking, computers can only executeprograms written in low-level languages. Thus, programs written in a high-level language have to beprocessed before they can run. This extra processing takes some time, which is a small disadvantage ofhigh-level the advantages are enormous. First, it is much easier to program in a high-level language. Programswritten in a high-level language take less time to write, they are shorter and easier to read, and they are morelikely to be correct. Second, high-level languages areportable, meaning that they can run on different kindsof computers with few or no modifications. Low-level programs can run on only one kind of computer andhave to be rewritten to run on to these advantages, almost all programs are written in high-level languages.


Related search queries