Best afterThe elif ladder: order matters·Modular arithmetic: wrapping around

FizzBuzz

FizzBuzz is the classic warm-up: count to 15, but say Fizz for multiples of 3, Buzz for multiples of 5, and FizzBuzz for both. It looks trivial — until the order of your tests quietly hides a whole case.

For 1 to 15, say Fizz for multiples of 3, Buzz for multiples of 5, FizzBuzz for both, else the number.

FizzBuzz — the branch you can never reach execution-derived · CPython
8        result.append("FizzBuzz")9    else:
variables
state after line 1 runs
variablevalue
result[]
step 1 / 65

Click a line, drag the slider, or use the keys.

What you are looking at

Watch the result list fill as i climbs from 1 to 15.

This is a milestone — it puts several earlier ideas together into one small program.

Every state you see came from running the program under CPython's tracer at build time — see how GlassBox stays honest.