Lesson 005: List and dict comprehensions
Focus
Anchor one invariant before you branch mentally: Intermediate drills List and dict comprehensions; spin token 99347 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence5mixesList and dict comprehensions; spin42280. - Ritual: Describe falsifying evidence that would veto this pattern.
- Own one invariant tied to
Intermediate.
Example (LESSON_UID = "intermediate-005")
# Intermediate drill L005 topic-0 micro-4 pattern-9
LESSON_UID = "intermediate-005"
spin_a, spin_b, spin_c = 366, 438, 923
def helper(x, bias=14):
return (x * bias + 4) % 5009
samples = [helper(5 + k) for k in range(3 + 0 % 4)]
print(samples, max(samples) - min(samples))
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-5.txt"
snap = [18, 392, 766]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (923 + 131))
Practice
Practice 39: Clone twice: expand literals vs shrink loops; compare narrative. Literal nudge 39.
Fingerprints
- lesson_uid:
intermediate-005 - umbrella band:
List and dict comprehensions(5/10) - lesson_index:
157