Class 22 — Wednesday March 24

Look at the map

asian-lives-matter

Look both ways


Agenda


To do


Examples


Some datasets


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 associaton 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

Problem robotomy.py

Door (locked / unlocked): locked

Turn around

Door (locked / unlocked): Unlocked

Open the door

Light (on / off): on

Enter the room

Door (locked / unlocked): unlocked

Open the door

Light (on / off): Off

Turn on the light

Enter the room



Raining cats and dogs (English idiom)

raining cats and dogs

 


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