Python for Data Analytics • Lesson 9
Dictionaries
Learn how Python dictionaries store information using key-value pairs and how to access, add, update, remove and process data.
0 of 8 concepts completed
Complete the activity and related MCQ to unlock the next concept.
What Is a Dictionary?
A dictionary stores data as key-value pairs inside curly braces { }. Instead of numeric positions, you look values up by their named keys.
Learn by Seeing
Keys map to values
student = {
"name": "Aman",
"age": 21,
"course": "Python"
}Each key on the left identifies the value on the right.
A dictionary maps each key to its value. Click any pair:
selected pair
key: "name" → value: "Aman"
The key on the left names the value on the right.
Interactive Activity
In the pair "name": "Aman", what is the key?
Hint: The key is on the left of the colon.
Python Analyst Mindset
Name your fields, not your positions
Positions are easy to mix up; names are not. Dictionaries let you write product["price"] instead of record[2] — code that reads like the record itself and survives when a column is inserted.
Create
Wrap key-value pairs in { }.
Look up
dict[key] or dict.get(key).
Grow
Assign a new key or update an existing one.
Inspect
keys(), values(), items().
Frequently Asked Questions
Dictionaries — FAQs
dict[key] raises a KeyError for missing keys. get() returns None (or a default) instead — safer for unknown data.
Yes. Values can be any type, and you can even nest other dictionaries as values.
Yes, since Python 3.7 dictionaries preserve insertion order, though you should not rely on that for logic.
No. Assigning the same key again overwrites the value — the dictionary has only one entry per key.
Lesson Summary
What you learned
Dictionaries map named keys to values.
dict[key] reads or replaces the value.
Assign a new key to add; pop(key) to remove.
Safely reads a value with an optional default.
Explore the dictionary from three angles.
Test for keys and store structured records.