Post date: Oct 18, 2011 11:38:0 PM
Announcements
Thursday's class will be held in 228 Gould Simpson for those who have not finished the current project
There is a football game beginning at 6:00 pm 20-Oct. Could be difficult to park?
We will not be having a quiz or in-class activity
We will be having lab next Monday, where attendance for the entire lab counts
The D2L Quiz on while loops (chapters 8 and 9) is still open. 15 of you have not made one attempt. Just do it.
Homework
Work on Project 6: MindNumber
If you haven't already done so, take the most recent quiz for Chapters 8 and 9
Lecture Outline
Top down design
Express an algorithm in terms of smaller problems
Design the smaller problems with a function name, parameters, and what is should return
Then write and test the functions one at a time
Example completed in last week's lecture that is very relevant for the current project
secretNum = generateSecretNumber()
printInformation()
while not won and attempts < 32
attempt = user's guess from the keyboard
digitsFound = uniqueDigitsFound(secretNumber, attempt)
inCorrectPosition=digitsInCorrectPosition(secretNumber, attempt)
print 'Digits found: ', digitsFound
print 'Correct position', inCorrectPosition
won = corrrectPosition == 5
if won:
print happiness
if attempts >= 32:
print sadness
Racquetball Simulation functions derived in Chapter 9
printIntro()
probA, probB = getInputs() # return probabilities of players winning volley when serving
winsA, winsB = simNGames(n, probA, probA)
scoreA, scoreB = simOneGame(probA, probA)
printSummary()
Code demo: simOneGame and simNGames; one function at a time