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

Python Intermediate — 121: Budget stdlib wedges with fresh literals centred on `collections.Counter, defaultdict, deque` [261743]

Lesson 121: collections.Counter, defaultdict, deque

Focus

Compare against yesterday's mental model politely: Intermediate drills collections.Counter, defaultdict, deque; spin token 1015291 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-121")

# Intermediate drill L121 topic-12 micro-0 pattern-8
LESSON_UID = "intermediate-121"
spin_a, spin_b, spin_c = 53, 661, 874

pairs = [(53, 29), (0, 12), (8, 119)]
flat = 1
for left, right in sorted(pairs):
    print(left ^ right + flat % 997)

from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as scratch:
    target = Path(scratch) / "scratch-121.txt"
    snap = [134, 191, 248]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (874 + 131))

Practice

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

Fingerprints