k = 10 / 3
l = k <= 3 or True
The value for l in this code returns True. How is this possible? In the order of evaluation, comparisons are higher prioritised than the "or, not, and" operators.
k = 10 / 3
l = k <= 3 or True
The value for l in this code returns True. How is this possible? In the order of evaluation, comparisons are higher prioritised than the "or, not, and" operators.
They do have a higher priority, but, the or operator works by:
The expression
x or yfirst evaluatesx; ifxis true, its value is returned; otherwise,yis evaluated and the resulting value is returned.
Since k is 3.3333333333333335, the expression k <= 3 is False, True is going to be evaluated (to itself) and returned making l == True.