Recall & Review
beginner
What is a dictionary in Python?
A dictionary is a collection of key-value pairs where each key is unique and used to access its corresponding value quickly.
Click to reveal answer
beginner
Why are dictionaries useful compared to lists?
Dictionaries allow fast lookup of values using keys, unlike lists which require searching through elements one by one.
Click to reveal answer
beginner
How do dictionaries help in real-life programming?
They store data with meaningful keys, like a phone book where you find a number by a person's name, making data easy to find and organize.
Click to reveal answer
intermediate
What happens if you try to use a non-unique key in a dictionary?
The new value replaces the old one for that key, because keys must be unique in a dictionary.
Click to reveal answer
intermediate
How does dictionary access time compare to list access time?
Dictionary access by key is very fast (almost instant), while list access by searching is slower because it checks items one by one.
Click to reveal answer
What is the main advantage of using a dictionary over a list?
✗ Incorrect
Dictionaries allow quick access to values by using unique keys.
In a dictionary, what must be unique?
✗ Incorrect
Keys in a dictionary must be unique to identify each value.
Which of these is a real-life example of a dictionary?
✗ Incorrect
A phone book uses names as keys and numbers as values, like a dictionary.
What happens if you add a key that already exists in a dictionary?
✗ Incorrect
Adding an existing key updates its value, replacing the old one.
Which operation is generally faster in a dictionary than in a list?
✗ Incorrect
Looking up a value by key is very fast in dictionaries.
Explain why dictionaries are preferred when you need to find data quickly.
Think about how you find a phone number by name.
You got /4 concepts.
Describe a real-life situation where using a dictionary would be helpful.
Imagine you want to find something fast by a label or name.
You got /4 concepts.