Lesson 046: Exceptions: catching, chaining, guarding
Focus
Compare against yesterday's mental model politely: Intermediate drills Exceptions: catching, chaining, guarding; spin token 440827 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence6mixesExceptions: catching, chaining, guarding; spin34827. - Ritual: Sketch control flow as ASCII before trusting output.
- Own one invariant tied to
Intermediate.
Example (LESSON_UID = "intermediate-046")
# Intermediate drill L046 topic-4 micro-5 pattern-6
LESSON_UID = "intermediate-046"
spin_a, spin_b, spin_c = 652, 315, 829
start = 23 + 5 % 5
leap = 2
span = 10
bucket = []
for idx in range(start, start + span):
bucket.append(idx * (spin_a % 37 + leap))
squares = tuple(x * x if x % 2 == (5 % 2) else -x for x in bucket[-4:])
print(bucket, squares)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-46.txt"
snap = [59, 720, 390, 60]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (829 + 131))
Practice
Practice 12: Swap print order once; reconcile dependency thinking. Literal nudge 12.
Fingerprints
- lesson_uid:
intermediate-046 - umbrella band:
Exceptions: catching, chaining, guarding(6/10) - lesson_index:
1476