Python Quest

Learning map · Track 6 · intermediate

Core Data Structures

Real programs rarely work with one value at a time. A shop has hundreds of products, a class has dozens of students, a sensor produces a reading every minute. This track teaches the four built-in collections Python gives you to hold that data — lists, tuples, dictionaries and sets — and the everyday patterns for working with them: indexing and slicing, counting and grouping with dictionaries, removing duplicates and comparing groups with sets, navigating nested records shaped like JSON, and transforming whole collections in one readable line with comprehensions.

It is written for learners who already know variables, conditions, loops and functions. Every lesson is built around realistic data — invoices, gradebooks, inventories, attendance sheets, survey answers — and you write and run real functions that are graded automatically, including the edge cases that break careless code: empty collections, duplicates, missing keys and inputs that must not be changed. You also learn the mistakes that cause real bugs, such as two names sharing one list, and finish by choosing the right structure for a job and building a small gradebook and inventory system step by step.

By the end of this track you can

  • Create, index, slice and modify lists, and explain when a method changes a list in place versus returning a new one
  • Store and look up data by key with dictionaries, and use them to count, group and invert data safely, including missing keys
  • Use tuples for fixed records and unpacking, and sets for uniqueness, fast membership tests and comparing groups
  • Navigate and summarise nested data such as lists of records and dictionaries of lists
  • Write list, dict and set comprehensions and sort records by one or several keys
  • Avoid aliasing bugs by knowing when data is shared, copied shallowly or copied deeply, and choose the right structure for a task

Lessons

  1. 1Lists: many values under one nameStore an ordered collection of values in a list, read items by position, and check length and membership.30 min · 4 exFree
  2. 2Changing lists: methods and mutabilityGrow, shrink and reorder lists with append, insert, remove, pop, extend and sort, and know when a list is changed in place.40 min · 4 exMembers
  3. 3Slicing: taking part of a listTake ranges of items with start:stop:step slices, copy lists with [:], and reverse with [::-1].35 min · 4 exMembers
  4. 4Tuples and unpackingUse tuples for fixed records that should not change, unpack them into names, and collect the rest with starred unpacking.35 min · 4 exMembers
  5. 5Dictionaries: looking things up by keyStore values under meaningful keys, read them safely with get(), and add, update and delete entries.40 min · 4 exMembers
  6. 6Dictionary patterns: count, group, invertLoop over keys, values and items, and use dictionaries to count occurrences, group records, invert mappings and total by category.45 min · 5 exMembers
  7. 7Sets: unique values and group comparisonsRemove duplicates, test membership quickly, and compare groups with union, intersection and difference.35 min · 4 exMembers
  8. 8Nested structures: records and JSON-like dataWork with lists of dictionaries, dictionaries of lists and deeper JSON-shaped data by chaining lookups step by step.45 min · 4 exMembers
  9. 9Comprehensions: building collections in one lineWrite list, dict and set comprehensions with filters, and know when a plain loop is clearer.40 min · 5 exMembers
  10. 10Sorting records with key functionsSort records by any field with key=lambda, reverse the order, break ties with tuple keys, and mix ascending and descending.40 min · 4 exMembers
  11. 11Copying and aliasing: when two names share one listUnderstand that assignment shares objects, tell == from is, and choose between shallow and deep copies to avoid mutation bugs.40 min · 4 exMembers
  12. 12Choosing a structure: a gradebook projectWeigh lists, tuples, dictionaries and sets against each other, then build a class gradebook step by step.60 min · 5 exMembers