Required Books:

• Python for Software Design: How to Think Like a Computer Scientist by Allen B. Downey.

ISBN-13: 9780521725965
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/

• Practical Programming: Computer Science Using Python by Jennifer Campbell.

Pragmatic Bookshelf; 1 edition (May 1, 2009)
ISBN-10: 1934356271
ISBN-13: 978-19343562721
First edition (May 1, 2009)

Detailed topics and readings for each meeting:

Main topics

1

Class Introduction: 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/

2

Variables, data types, statements and expressions: Lecture 1 & 2

Chapter 1 & 2 from Allen Downey’s book.

3

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

4

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

import random
random.randint(a,b)

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.

EXAMPLES:Repetition (Loops), nested loops, Sentinel loops: While sentinel loop (user will stop loop)

ists: Create a list and use list.append() and list.remove() to add elements to the list: list1.py, Month selected at random from a list:list_monthsRandom.py

LECTURES: LISTS

file:

Writing to a file: file_write.py

Pythons Modules (Math, and Random): Examples of Defined Functions: random.random(), random.randint(min, max), len(), random.choice('abc'), math.sqrt(x), math.pow(x, y),

Chapters 7, 8 and 11 from Allen Downey’s Book

Book examples: Lists, file and Exceptions

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)

Examples of Functions that return values: Square numbers, Converting temperatures

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

Draw shapes using functions: Shapes3 , function to draw a Box