Class 22 — Wednesday March 14

Test examples and "while" examples

This is the beginning of anyting you want

Look both ways


Agenda


To do


More 'while' Examples and Test Review


Problem keep_quizzing.py

Enter desired score: 92

Enter quiz score: 87

Enter quiz score: 88

Enter quiz score: 97

Enter quiz score: 99

Congratulations! Your average score is 92.75


Enter desired score: 88

Enter quiz score: 90

Congratulations! Your average score is 90.0



Problem first_five_proper.py

Enter name: Elizabeth

Enter name: Rachel

Enter name: Luther

Enter name: ray

Enter name: Nate

Enter name: Upsorn

[Elizabeth, Rachel, Luther, Nate, Upsorn]


Enter name: Aphrodite

Enter name: Hera

Enter name: Demeter

Enter name: Diana

Enter name: Cupid

[Aphrodite, Hera, Demeter, Diana, Cupid]



Test prep: leap_year.py


Test prep: binary_checkerboard.py


Test prep: guess_computer_number.py


Agenda


To do


Examples


Some data sets


Problem romantic.py

Some program runs

Enter Roman numeral: V

5

Enter Roman numeral: d

500

Enter Roman numeral: 0

Unknown



Problem unromantic.py

Some program runs

RecursionError: maximum recursion depth exceeded during compilation



Discussion

flora_to_color = { 'spruce': 'green', 'apple': 'red', 'shamrock': 'green',

  'banana': 'yellow', 'potato': 'brown', 'eggplant': 'purple' }

flora_to_color[ 'lemon' ] = 'yellow'

flora_to_color[ 'potato' ] = 'golden'

would cause flora_to_color to lose its association of mapping potato to brown — its association with 'potato' is now only to golden.

the_keys = flora_to_color.keys()

the_values = flora_to_color.values()

While there are never any duplicates in the keys, depending upon the dictionary there may be duplicates in the values.


Problem even_odd.py

Some program runs

Enter a number: 3

3 odd

Enter even or odd: even

a number is even if its remainder divided by 2 is 0

Enter a number: 6

6 even

Enter even or odd: odd

a number is odd if its remainder divided by 2 is 1



Problem good_doggie.py

http://www.cs.virginia.edu/~cs1112/datasets/csv/puppies.csv

  • Sequential
  • Nested
  • Mixture of nested and sequential

Where am I

jpc @ love is love

 


  🦆 © 2022 Jim Cohoon   Resources from previous semesters are available.