Week 10 — Tuples, Dictionaries & Sets
Welcome to your Week 10 Start Here page.
Why this matters
A biology major who maps each sample label to its count and a city-planning intern who turns a day of bike-share trips into the set of docks riders used both rely on picking the container that fits the job.
In plain language
Last week you kept a pile of values in one list and reached each one by its position; this week you meet three more containers, each built for a different job. A tuple (a fixed record whose parts stay together and never change) holds something like one bike trip. A dictionary (a lookup table that finds a value by its name instead of its position) holds something like your reading log, with each book's title pointing to its pages. A set (a collection that keeps one copy of each value) answers "which ones showed up?" without counting anyone twice. As always, you predict what each program prints and then run it to check.
- Already covered: lists, list methods, and alias versus copy from Week 9.
- This week: tuples, unpacking, dictionaries, KeyError, counting, and sets.
- How they connect: a dictionary is walked by the same for loop you used on lists.
- Where we're going next: Week 11, Strings in Depth & Text Processing.
Focus
Which container fits the job: a list, a tuple, a dictionary, or a set?
By the end of this module, you should be able to:
- [ ] look up and update a value in a dictionary by its key
- [ ] repair a KeyError with get or an in test
- [ ] use a set to drop repeats and pick the right container
To-do
Plan your week
- Read Chapter 10 (about 50 minutes), then the lecture and slides.
- Work the lecture tutorial (60–90 minutes) and the practice set (about 20 minutes).
- Do the Coding Lab (about 90 minutes), the discussion, and the assignment.
- Take the quiz.
This week's checkpoint: predict what print(log["comics"]) does, run it, and repair it two ways.
You've got this
Predict, then run, and ask your instructor if a step snags.
Built with The Course Maker · samples.thecoursemaker.com