Best afterChoosing one branch with if / else

The elif ladder: order matters

An if/elif ladder stops at the first branch that's true and skips the rest. So the order of the tests is the logic — put the loosest band first and the strict ones become unreachable. Watch a 95 get the wrong grade.

Grade a score of 95: 90+ is an A, 80+ a B, 70+ a C, anything lower a D.

Loosest test first execution-derived · CPython
4elif score >= 70:5    grade = "C"6elif score >= 80:7    grade = "B"8elif score >= 90:9    grade = "A"
variables
state after line 1 runs
variablevalue
score95
step 1 / 3

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

What you are looking at

Watch grade, and which test the ladder stops at.

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