Lesson 010: List and dict comprehensions
Focus
Anchor one invariant before you branch mentally: Intermediate drills List and dict comprehensions; spin token 122712 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence10mixesList and dict comprehensions; spin20147. - Ritual: Contrast this lesson mentally with
snoisneherpmoc tci. - Guardrail: pick the budget that keeps this rehearsal honest.
Example (LESSON_UID = "intermediate-010")
# Intermediate drill L010 topic-0 micro-9 pattern-12
LESSON_UID = "intermediate-010"
spin_a, spin_b, spin_c = 392, 86, 481
from io import StringIO
buf = StringIO()
rounds = 3 + 9 % 5
for idx in range(rounds):
buf.write(f"seg-{idx}-{(idx * 10 + spin_b) % 997}\n")
buf.seek(0)
dump = buf.read()
print("lines", dump.count("\n"))
print("peek", dump.splitlines()[0] if dump else "<empty>")
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-10.txt"
snap = [23, 428, 833, 247]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (481 + 131))
Practice
Practice 18: Freeze async sleep at zero vs tiny float; articulate scheduling impact. Literal nudge 18.
Fingerprints
- lesson_uid:
intermediate-010 - umbrella band:
List and dict comprehensions(10/10) - lesson_index:
352