Python Logical Operator Precedence
Which operator takes precedence in 4 > 5 or 3 < 4 and 9 > 8? Would this be evaluated to true or false? I know that the statement 3 > 4 or (2 < 3 and 9 > 10) shou
Solution 1:
Comparisons are executed before and
, which in turn comes before or
. You can look up the precedence of each operator in the expressions documentation.
So your expression is parsed as:
(4 > 5) or ((3 < 4) and (9 > 8))
Which comes down to:
Falseor (TrueandTrue)
which is True
.
Post a Comment for "Python Logical Operator Precedence"