Module 4 · Tuples and dictionaries · Lesson 6 of 6
Quiz
Five questions on mutability, tuples, dictionaries and their methods. Run each snippet in your head first.
1
Which statement raises an error?
t = (1, 2, 3)
2
What is one_item?
one_item = (7,)
3
What does this print?
d = {"a": 1, "b": 2}
print(d.get("z", 0))4
What does in test on a dictionary?
ages = {"Ada": 36}
print(36 in ages)5
What does ages.items() yield each loop?
for x in ages.items():
print(x)Lists, tuples and dictionaries give you a collection for every job: ordered and editable, fixed and safe, or looked up by name. Next in this module: handling the unexpected, with exceptions.