Today is Monday June 08, 2009. Week Five starts. At the end of this week we will have the last Homework Exam. Next week is the final week, the Final Exam will be on Thu, in two parts. Things we discussed: numbers, strings, operators, expressions, values, variables and assignment variables, booleans, if statements, loops (while, for) and simple data structures: sequences (strings, tuples, lists) and dictionaries. functions (methods, procedures, subroutines) their purpose being to help control the complexity of the problem/program. With them you can organize your code by presenting it in stages (layers). Also make possible code reuse, to some extent. Things still to be discussed: work with files (reading data from a text file and summarizing it) understanding classes and objects: they represent the next step from functions Tomorrow: magic squares with nested lists and/or dictionaries. Today we start from the following situation, involving our current knowledge of functions. So here's what could happen if you want to rely on functions when you write the code for Hangman: import random def process(letter): global dashes for index in range(len(secret)): if secret[index] == letter: dashes = dashes[0:index] + letter + dashes[index+1:] words = ("python", "something", "nothing", "wednesday") index = random.randrange(len(words)) secret = words[index] dashes = "-" * len(secret) while dashes != secret: letter = raw_input(dashes + ": ") process(letter) print "Good job, you guessed it." So we discussed some rules and examples in simple contexts. In the end we had this: balance = 0 def deposit(amount): global balance print "I am depositing", amount, "into", balance balance = balance + amount report() def withdraw(amount): global balance print "I am withdrawing", amount, "from", balance balance = balance - amount report() def report(): print "The account balance is:", balance The final question was: this is for one balance, one person. How do we do this for a lot of people, for each one of us. Tue lecture assignment is: either tell me how you plan approaching this or identify shortcomings for this approach. If I ever introduce a new approach to you I will at least be able to say that I eliminated the shortcomings that you identified.