Lesson 001: List and dict comprehensions
Focus
Compare against yesterday's mental model politely: Intermediate drills List and dict comprehensions; spin token 53728 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence1mixesList and dict comprehensions; spin57934. - Ritual: Add one doctest-style assertion comment above hottest print.
- Guardrail: name the surprise that triggered when literals shifted.
Example (LESSON_UID = "intermediate-001")
# Intermediate drill L001 topic-0 micro-0 pattern-8
LESSON_UID = "intermediate-001"
spin_a, spin_b, spin_c = 984, 340, 868
pairs = [(35, 24), (0, 0), (1, 113)]
flat = 1
for left, right in sorted(pairs):
print(left ^ right + flat % 997)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-1.txt"
snap = [14, 11, 8]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (868 + 131))
Practice
Practice 11: Freeze async sleep at zero vs tiny float; articulate scheduling impact. Literal nudge 11.
Fingerprints
- lesson_uid:
intermediate-001 - umbrella band:
List and dict comprehensions(1/10) - lesson_index:
1