0
0
Pythonprogramming~5 mins

Why dictionaries are used in Python - Quick Recap

Choose your learning style9 modes available
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?
AFast access to values using keys
BStores only numbers
CKeeps items in order
DUses less memory
In a dictionary, what must be unique?
AValues
BNeither keys nor values
CBoth keys and values
DKeys
Which of these is a real-life example of a dictionary?
AA phone book with names and numbers
BA list of grocery items
CA stack of books
DA queue of people
What happens if you add a key that already exists in a dictionary?
AAn error occurs
BThe old value is replaced
CThe key is duplicated
DThe dictionary deletes the key
Which operation is generally faster in a dictionary than in a list?
AAdding an item
BRemoving an item
CLooking up a value by key
DSorting items
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.