Dictionaries and Data
Model real data with dicts, tuples, sets and nested structures.
Real programs juggle records, not single values. You will store data under keys with dictionaries, count and group with them, and rely on their insertion order. You will choose between tuples and lists, use tuples as keys, unpack them with enumerate and zip, compare groups with sets, sort records by several fields, copy nested data shallowly or deeply, and build dicts and sets with comprehensions. The course ends with small realistic programs: an inventory report, an order summary from JSON-shaped data, a word-frequency ranking, a gradebook and a price-list merge.
What you will learn
- Dictionaries
- Counting and grouping
- Tuples and unpacking
- Sets
- Sorting with key=
- Copying nested data
- Dict and set comprehensions
Lessons
- 1
Dictionaries
Store values under keys, look them up safely, add, update, merge and remove entries, and check which keys exist.
12 exercises
- 2
Looping Over Dictionaries
Walk keys, values and pairs, rely on insertion order, count things, group things, and delete safely while looping.
11 exercises
- 3
Tuples and Unpacking
Group fixed values in tuples, choose between a tuple and a list, use tuples as keys, unpack them into names, and loop with enumerate and zip.
13 exercises
- 4
Sets
Keep unique values, test membership fast, compare groups with set operations, and remove duplicates without losing order.
13 exercises
- 5
Nested Data and Sorting
Work with lists of records, avoid shared inner lists, sort any collection by any field, and copy nested data shallowly or deeply.
15 exercises
- 6
Dict and Set Comprehensions
Build and filter dicts and sets in one expression, tell a set comprehension from a dict one, and know when inverting a dict loses data.
10 exercises
- 7
Putting It Together
Build five small data programs: an inventory report, an order summary, a word ranking, a gradebook and a price merge.
10 exercises
How you practice
You practice in the browser and every exercise gives you feedback right away. This course uses these formats:
- Code exercise: 31
- Fix the bug: 13
- Predict the output: 13
- Type the answer: 8
- Multiple choice: 6
- Fill in the blank: 5
- Reorder lines: 3
- Spot the bug: 2
- Select all that apply: 2
- Match the pairs: 1
Aligned to
- Data Collections - Tuples, Dictionaries, Lists, and Strings
- 3.2Collect and process data using tuples
- 3.3Collect and process data using dictionaries
- Software Development Fundamentals
- SDF-Data-StructuresFundamental Data Structures
Proto Node Labs is not affiliated with or endorsed by Python Institute and ACM / IEEE-CS / AAAI. Exam names are trademarks of their owners.