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

Python Basic — 144: Encode stream caps with print-as-contract centred on `Scope, locals, and shadowing pitfalls` [495521]

Lesson 144: Scope, locals, and shadowing pitfalls

Focus

Let the literals expose mistaken assumptions quickly: Basic drills Scope, locals, and shadowing pitfalls; spin token 1222294 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "basic-144")

# Basic drill L144 topic-14 micro-3 pattern-1
LESSON_UID = "basic-144"
spin_a, spin_b, spin_c = 741, 724, 480

left, right = spin_a + 144, spin_b + 3
print(divmod(left + 3, max(3, (spin_c % 9) + 2)))
acc = (310 + 144) % (181 % 881 + 3 + 1)
for step in range(3 + (14 % 4)):
    acc = acc * (spin_a % 11 + 3) % 100003
    if acc % (spin_b % 8 + 2) == 0:
        print("hit", step, acc)
print("trail", acc)

Practice

Practice 32: Shadow one variable purposely to spotlight scope quirks. Literal nudge 32.

Fingerprints