UNIT 02 · TOPIC 18
Dictionaries
Dictionaries map unique keys to values and are useful for records and fast lookups.
The idea
Dictionaries, simply explained
Dictionaries map unique keys to values and are useful for records and fast lookups.
01
See the big picture
How the idea flows
Read the diagram as a simple path: begin with a problem, use the Python idea, then verify the result.
02
Everyday connection
Real-life example
↗
A phone contact book maps each person's name to their phone number.
03
Learn by doing
Python code example
PYTHONExample
contact = {'Riya': '555-0142'}
contact['Aman'] = '555-0188'
print(contact['Riya'])Expected result
555-0142Try it: Change one value in the code, predict what will happen, then run it and compare your answer.
04
Keep this in mind
Key takeaways
- Dictionaries map unique keys to values and are useful for records and fast lookups.
- Think of a real problem where dictionaries could save time or organize information.
- Test small changes and read the result carefully before moving to a bigger program.
Quick self-check
Can you explain it in your own words?
What is the main idea of Dictionaries?
Dictionaries map unique keys to values and are useful for records and fast lookups.
Where could you see this idea in everyday life?
A phone contact book maps each person's name to their phone number.
