Best afterValues and names
Numbers have types: int vs float
Every value has a type, and the type decides what an operator does. Nowhere is that clearer than division: Python has two division operators, and they give you different numbers — and different types. Watch the average come out whole or fractional.
Find the average of total = 7 shared between count = 2 (we want 3.5).
Dividing with // drops the remainder execution-derived · CPython
variables
state after line 1 runs
| variable | value |
|---|---|
total | 7 |
step 1 / 3
Click a line, drag the slider, or use the ← → keys.
What you are looking at
Watch avg, and notice whether it lands as a whole int or a fractional float.
- Buggy —
avg = total // countuses floor division:7 // 2 = 3, anint. The half is gone — wrong for an average. - Procedural —
avg = total / countuses true division:7 / 2 = 3.5, afloat. A single slash keeps the fraction. Same numbers, different operator, different type.
Every state you see came from running the program under CPython's tracer at build time — see how GlassBox stays honest.