Lesson 059: Branching with if, elif, and else
Focus
Prints are breadcrumbs, not ornamentation: Basic drills Branching with if, elif, and else; spin token 498960 makes this page unlike its neighbours.
Key ideas
- Angle
Basic: micro cadence9mixesBranching with if, elif, and else; spin50677. - Ritual: Add one doctest-style assertion comment above hottest print.
- Guardrail: name the surprise that triggered when literals shifted.
Example (LESSON_UID = "basic-059")
# Basic drill L059 topic-5 micro-8 pattern-4
LESSON_UID = "basic-059"
spin_a, spin_b, spin_c = 562, 854, 798
score = 159
ladder = []
ladder.append("bronze" if score < (spin_a % 41 + 8) else "silver-ish")
ladder.append("gold" if score > (spin_b % 71 + 5) else "retry")
print(sorted(set(ladder)), score)
Practice
Practice 19: Shadow one variable purposely to spotlight scope quirks. Literal nudge 19.
Fingerprints
- lesson_uid:
basic-059 - umbrella band:
Branching with if, elif, and else(9/10) - lesson_index:
1913