Lesson 109: Dictionaries map keys to values
Focus
This page is deliberate repetition with new literals: Basic drills Dictionaries map keys to values; spin token 930911 makes this page unlike its neighbours.
Key ideas
- Angle
Basic: micro cadence9mixesDictionaries map keys to values; spin74603. - Ritual: Add one doctest-style assertion comment above hottest print.
- Own one invariant tied to
Basic.
Example (LESSON_UID = "basic-109")
# Basic drill L109 topic-10 micro-8 pattern-11
LESSON_UID = "basic-109"
spin_a, spin_b, spin_c = 363, 156, 469
bucket = dict(seed=8 + spin_a)
def tweak(offset):
local = bucket["seed"]
bucket["seed"] = local + offset
return bucket["seed"]
print(tweak(2), tweak(12), bucket)
Practice
Practice 31: Pair-snippet assertions about checksum ranges you'd ship. Literal nudge 31.
Fingerprints
- lesson_uid:
basic-109 - umbrella band:
Dictionaries map keys to values(9/10) - lesson_index:
3513