Lesson 038: Strings from literals to slicing
Focus
Compare against yesterday's mental model politely: Basic drills Strings from literals to slicing; spin token 315425 makes this page unlike its neighbours.
Key ideas
- Angle
Basic: micro cadence8mixesStrings from literals to slicing; spin14225. - Ritual: Add one doctest-style assertion comment above hottest print.
- Guardrail: name the surprise that triggered when literals shifted.
Example (LESSON_UID = "basic-038")
# Basic drill L038 topic-3 micro-7 pattern-6
LESSON_UID = "basic-038"
spin_a, spin_b, spin_c = 215, 654, 531
start = 22 + 7 % 5
leap = 8
span = 48
bucket = []
for idx in range(start, start + span):
bucket.append(idx * (spin_a % 37 + leap))
squares = tuple(x * x if x % 2 == (7 % 2) else -x for x in bucket[-4:])
print(bucket, squares)
Practice
Practice 23: Promote hottest literal into named constant; justify naming aloud. Literal nudge 23.
Fingerprints
- lesson_uid:
basic-038 - umbrella band:
Strings from literals to slicing(8/10) - lesson_index:
1234