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

Python Intermediate — 060: Decode iterator cadence with resource hygiene centred on `Classes encapsulating mutable state` [362718]

Lesson 060: Classes encapsulating mutable state

Focus

This page is deliberate repetition with new literals: Intermediate drills Classes encapsulating mutable state; spin token 523448 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-060")

# Intermediate drill L060 topic-5 micro-9 pattern-7
LESSON_UID = "intermediate-060"
spin_a, spin_b, spin_c = 960, 329, 52

src = [((k + 60) * spin_a + 9) % 241 for k in range(4 + 9 % 3)]
derived = [v * v if v % 2 == 0 else v + spin_b for v in src]
print("src", src)
print("derived", derived)
print("zip_sum", sum(x + y for x, y in zip(src, derived)))

from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as scratch:
    target = Path(scratch) / "scratch-60.txt"
    snap = [73, 55, 37, 19]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (52 + 131))

Practice

Practice 13: Attach property-style expectations referencing tuple shapes. Literal nudge 13.

Fingerprints