In Python, logical operators like and and or can stop checking values early, which is called short-circuit evaluation. This means Python may not check both parts of the expression if it already knows the result after looking at the first value.
With and: If the first value is
False, Python doesn't need to check the second value because the whole expression will beFalse.With or: If the first value is
True, Python stops because the whole expression will beTrue.
Now, let's look at two boolean variables:
a = True
b = FalseFor which expression will Python only check the first operand (i.e. short-circuit evaluation)?