Post date: Oct 13, 2011 9:40:28 PM
Announcements
Midterm statistics (If not in class today to get your test, see your grade on D2L. Your section leader will have your midterm in lab next Monday)
Average 86.8%
Median 91.7%
Min 46.3%
Max 100%
If you dispute any grade, show it to Rick for a regrade. You have one week to do this (5:00 pm Thursday October 20
Next Thursday class will be held in 228 Gould Simpson for those who have not finished the next project that will be assigned Monday during lab.
There is a football game beginning at 6:00 pm 20-Oct. Will be even more difficult to park
Homework
Read Pages 238..242 in Chapter 8
Read all of Chapter 9
Take Chapter 8-9 quiz before your next lab: while loops and top down design
Lecture Outline
See midterm answers and grading criteria ISTA130Test1ANSWERSCRITERIA.pdf
while loop patterns in Python (see Chapter 8, pages 238..242
Interactive input: Ask user if there is more input to determine an average
Sentinel loop: Enter a negative number ot quit to determine an average
Sentinel loop: Press enter to quit (a string == "" to determine an average)
Two ways to generate psuedo-random numbers
from random import randrange, random
print('Using randrange(start, stop)')
for lcv in range(10):
print(randrange(0, 9), end=' ')
print('\n')
print('Using random() to get 0 <= randomNumber < 1.0')
for lcv in range(4):
print(random(), end=' ')
Top Down Design.
Write an algorithm in English to help us implement the game of MindNumber
If you know of useful Python functions, use them
If you wish you had a function to solve a small problem, pretend you have the function, name it, pass the needed input as arguments, you can write the function tomorrow (the manana principle)
I have a randomly generated number that is five digits long where all digits are unique. Possible secret numbers include 01234, 59120, and 67891. Invalid secret numbers include 123456, 11234, and 1234.
Use deductive reasoning to determine this random secret number.
You have a maximum of 32 tries.
Attempt 14: 01234
Characters found: 5
Correct position: 5
...
Attempt 2: 09999
Digits found: 1
Correct position: 1
Attempt 1: 00000
Digits found: 1
Correct position: 1
Algorithm in English
secretNum = generateSecretNumber()
printInformation()
while not won and attempts < 32
attempt = user's guess from the keyboard
digitsFound = uniqueDigitsFound(secretNumberm, 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
Congratulations! You deduced the secret number in 14 attempts.