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

Python Intermediate — 016: Re-shape logging cadence with tuple witnesses centred on `Generator expressions and laziness` [676374]

Lesson 016: Generator expressions and laziness

Focus

Prints are breadcrumbs, not ornamentation: Intermediate drills Generator expressions and laziness; spin token 188628 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-016")

# Intermediate drill L016 topic-1 micro-5 pattern-2
LESSON_UID = "intermediate-016"
spin_a, spin_b, spin_c = 832, 806, 412

blob = "16|F"
head, sep, tail = blob.partition("|")
print(tuple(zip(head, reversed(tail))))
filt = [ch for ch in head if ord(ch) % (spin_a % 5 + 2) != 0]
print("filt", filt)

from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as scratch:
    target = Path(scratch) / "scratch-16.txt"
    snap = [29, 870, 720, 570]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (412 + 131))

Practice

Practice 33: Clone twice: expand literals vs shrink loops; compare narrative. Literal nudge 33.

Fingerprints