Learn Without Walls
← Back to Module 8

Module 8 Quiz

Dictionaries & Tuples — 12 Questions

1. Which of the following correctly creates a dictionary?

2. What happens when you access a key that does not exist using square brackets?

3. What does my_dict.get("key", "default") return if "key" is not in my_dict?

4. What does my_dict.items() return?

5. Which of the following can be used as a dictionary key?

6. What is the output of this code?

d = {"a": 1, "b": 2}
d["a"] = 10
d["c"] = 3
print(len(d))

7. Which of the following creates a single-element tuple?

8. What does tuple unpacking allow you to do?

9. Why can't you use a list as a dictionary key?

10. What is the output of this code?

t = (1, 2, 3, 2, 2)
print(t.count(2))

11. What does pop() do when called on a dictionary?

12. Which data structure would you choose to store a fixed (x, y) coordinate pair?

Back to Module 8