Lesson 004: List and dict comprehensions
Focus
Anchor one invariant before you branch mentally: Intermediate drills List and dict comprehensions; spin token 47714 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence4mixesList and dict comprehensions; spin11846. - Ritual: Predict the checksum line, then reconcile on mismatch.
- Own one invariant tied to
Intermediate.
Example (LESSON_UID = "intermediate-004")
# Intermediate drill L004 topic-0 micro-3 pattern-12
LESSON_UID = "intermediate-004"
spin_a, spin_b, spin_c = 56, 600, 869
from io import StringIO
buf = StringIO()
rounds = 3 + 3 % 5
for idx in range(rounds):
buf.write(f"seg-{idx}-{(idx * 4 + 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-4.txt"
snap = [17, 80, 143, 206, 269, 332]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (869 + 131))
Practice
Practice 35: Export checkpoints into bullets for teammate review. Literal nudge 35.
Fingerprints
- lesson_uid:
intermediate-004 - umbrella band:
List and dict comprehensions(4/10) - lesson_index:
118