Best afterA comparison is a yes/no value
Choosing one branch with if / else
Two back-to-back if statements are two independent decisions — both can run. When you meant 'do one or the other', that's a bug, and the last branch silently wins. Watch grade get set, then overwritten.
Grade a score of 85: 'distinction' for 80 and up, otherwise 'pass' for 50 and up.
Two ifs both run execution-derived · CPython
variables
state after line 1 runs
| variable | value |
|---|---|
score | 85 |
step 1 / 5
Click a line, drag the slider, or use the ← → keys.
What you are looking at
Watch grade: it's set once, then changed again.
- Buggy — Both
ifs test true for 85, sogradebecomes'distinction'and is then overwritten by'pass'. Two separate ifs, both fired. - Procedural — Joining them with
elifmakes them one decision — the moment the first matches, the rest are skipped, sogradestays'distinction'.
Every state you see came from running the program under CPython's tracer at build time — see how GlassBox stays honest.