Cambridge University Press
Second edition (March 2009)
Free online access to required textbook “How to Think Like a Computer Scientist”: http://www.greenteapress.com/thinkpython/thinkCSpy/html/
Pragmatic Bookshelf; 1 edition (May 1, 2009)
First edition (May 1, 2009)
Detailed topics and readings for each meeting:
What is computer Science? What is an algorithm?
How to install, run and use Python’s software needed for this class.
Introduction to Programming in Python
Chapter 1 from Jennifer Campbell's book.
Please note that a free copy of this book (Downey’s book) is available online at:http://www.greenteapress.com/thinkpython/thinkCSpy/html/
EXAMPLES: hello1, add.py, addition1,
Chapter 1 & 2 from Allen Downey’s book.
Control flow: Branching (If, elif, and else.)
Boolean logical operators and expressions.
Branching: Selections statements (If, elif, and else.)
Chapters 2 and 4 from Allen B. Downey's book.
Chapter 2 & 3 from Jennifer Campbell's book.
EXAMPLES: Control Structure
Repetition (Loops): Repetition (Iteration using for and while loops.)
Lectures: for loops, while Loops , nested Loops
1) Integer Random numbers: Need to import random at the beginning of your program
Please note that using random.randint(a,b) produces the following range:
# Return a random integer N such that a <= N <= b.
#Example: random.randint(1,6) produces 1 <= N <= 6.
This can produce 1 or 6 or 4 or 3
Chapters 5.1-5.7 and 7 from Allen Downey’s Book.
Chapter 7 from Jennifer Campbell's book.
Writing to a file: file_write.py
Chapters 7, 8 and 11 from Allen Downey’s Book
Review of built in functions in Python (this is a good review for all functions covered so far including String and lists.
Modular Programming: Structuring larger programs (Modules and Functions): Lectures: Functions
Pythons Modules (Math, and Random) , python defined Functions, User Examples of Defined Functions: random.random(), random.randint(min, max), len(), random.choice('abc'), math.sqrt(x), math.pow(x, y),
User Defined Functions:
Chapters 3 and 6 from Allen Downey’s Book.
Examples of Defined modules and functions: Math, and Random.
Integer random number examples: random.py, random_numbers1, Roll dice 100 times ,Compute average for 20 random numbers between 1 and 1,000,000, Float random numbers examples (also printing only 2 decimal values): random_numbers2,
Random numbers & user defined functions: Random functions, generate a random word (5 letters), netid (generated randomly)
Examples of User-Defined functions that don't return a value: green Eggs, greenEggs_withFunctions2.py, Square numbers ,Square and cube Numbers, Square, cube and print, shapes1, shapes2 (not efficient-- see shape 3 for a better example)
It's possible for a python function to return multiple values at the same time (not allowed in other programming languages):Multiple Returns
Local Variables: Scope of local variables in functions
Global variables: Scope of Global variables