Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 1.44 KB

Python_05_problemset.md

File metadata and controls

44 lines (30 loc) · 1.44 KB

Python 5 - Dictionaries - Problem Set

  1. Write a script in which you construct a dictionary of your favorite things.

Some of my favorites:

Type Favorite
book Jitterbug Perfume
song Tom Petty - I Won't Back Down
tree Cedar
  1. Print out your favorite book.
print(fav_dict['book'])
  1. Print out your favorite book but use a variable in the key.
fav_thing = 'book'
print(fav_dict[fav_thing])
  1. Now print your favorite tree.

  2. Add your favorite 'organism' to the dictionary. Make organism the new key of fav_thing

fav_thing = 'organism'
print(fav_dict[fav_thing])
  1. Use a for loop to print out each key and value of the dictionary.

  2. Take a value from the command line for fav_thing and print the value of that item from the dictionary.

  3. Print out all the keys to the user so that they know what to pick from. Check out input(). Here is a link about input

  4. Change the value of your favorite organism.

  5. Get the fav_thing from the command line and a new value for that key. Change the value with the user inputted value. And print out a confirmation.