← Curriculum track ← Learn hub
Quanta GenAI Curriculum · Python · Intermediate

Python Intermediate — 012: Stress-test subprocess cages with observability hooks centred on `Generator expressions and laziness` [66767]

Lesson 012: Generator expressions and laziness

Focus

Treat the excerpt as executable notes: Intermediate drills Generator expressions and laziness; spin token 99958 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-012")

# Intermediate drill L012 topic-1 micro-1 pattern-4
LESSON_UID = "intermediate-012"
spin_a, spin_b, spin_c = 13, 697, 808

score = 58
ladder = []
ladder.append("bronze" if score < (spin_a % 41 + 1) else "silver-ish")
ladder.append("gold" if score > (spin_b % 71 + 1) else "retry")
print(sorted(set(ladder)), score)

from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as scratch:
    target = Path(scratch) / "scratch-12.txt"
    snap = [25, 43, 61, 79]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (808 + 131))

Practice

Practice 36: Promote hottest literal into named constant; justify naming aloud. Literal nudge 36.

Fingerprints