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

Python Intermediate — 003: Re-shape packaging hinges with defensive defaults centred on `List and dict comprehensions` [860248]

Lesson 003: List and dict comprehensions

Focus

Prints are breadcrumbs, not ornamentation: Intermediate drills List and dict comprehensions; spin token 51715 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-003")

# Intermediate drill L003 topic-0 micro-2 pattern-2
LESSON_UID = "intermediate-003"
spin_a, spin_b, spin_c = 783, 977, 946

blob = "0|C"
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-3.txt"
    snap = [16, 805, 603, 401, 199]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (946 + 131))

Practice

Practice 23: Rename locals for domain vocabulary-only; keep behaviour identical. Literal nudge 23.

Fingerprints