Boolean precedence

Boolean precedence

Three operators. One clear order.

Meet the order

1Flip
2Both
3Either

not binds most tightly. and comes next. or comes last.

See the grouping

False or True and not False
Truenot False becomes True
Try another expression

Use True, False, not, and, or, and parentheses.

These steps show how the expression groups. Python can skip a branch when it runs.

Parentheses change the grouping.

Same values. Different result.

Grouping is only half the story.

Python reads operands from left to right. If or finds True, it skips the right side. If and finds False, it does the same.

or(not False)

Right side skipped. The result is already True.

Change the left value to see what Python evaluates.