Make a fork, then make a local clone.
Complete these exercises in a file called dictionaries.py
in this repo. Commit your work as you go!
- Create a dictionary called
my_stats
with your name, age, and height. - Print out the string
"[name] is [age] years old with a height of [height]."
with[name]
,[age]
, and[height]
coming from your dictionary. - Delete your age from my_stats
- Create a dictionary called vocabulary_words that contains 4 vocabulary words from this course as keys and their definitions as values. (Hint: Look up at the wall if you can't think of any vocabulary words.)
- Write a program that counts how many times each letter appears in your full name. Return a dictionary that looks like this:
{'a':2, 'c':1, 'w':1}
- Write a program that counts how many times each letter appears in a random string. Return a dictionary that looks like this:
{'a':22, 'c':14, 'r':19, 'w':2}
- Write a program that counts how many times each letter appears in a file. Use the file
one_fish_two_fish.txt
in this repo to test your program. Return a dictionary. - Write a program that counts how many times each word appears in a random string. When given
"one fish two fish red fish blue fish"
it should return a dictionary that looks like this:{'one':1, 'fish':4, 'two':1, 'red':1, 'blue':1}
- Write a program that counts how many times each word appears in a file. Use the file
one_fish_two_fish.txt
in this repo to test your program. Return a dictionary. - Given a dictionary of items and their prices, write a program that returns the most expensive item. Hint: Look at the last slide in Dictionary Lecture to figure out how to iterate over a dictionary!
e.g. prices = { "banana": 4, "apple": 2, "orange": 1.5, "pear": 3 }
Your program should return "bananas"
Remember to commit and push all your changes!