Chapters
Python114 chapters

Exercises

Dictionaries

3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.

Exercise 1

Print the name, then look up a missing key without crashing.

Python
person = {"name": "Ada"}
# print the name, then the age as 'unknown'
Exercise 2

Print each key and value on its own line as key = value.

Python
person = {"name": "Ada", "born": 1815}
# print each pair
Exercise 3

Count how many times each word appears, without importing anything.

Python
words = ["a", "b", "a", "c", "a"]
counts = {}
# fill counts
print(counts)