0

Operator precedence

print(False == True or True) In the above code, output is True If == takes precedence over or, then shouldn't output be False as False is not equal to True.

10th Sep 2019, 8:02 AM
Meetu Shringi
Meetu Shringi - avatar
2 odpowiedzi
+ 2
I think it's because it evaluates false == true first which is false, and then it checks to see if the left or right of the or operator is true, if either side is true it will return true. false | true <right side also gets checked //true only left side gets checked > true|false //true false|false > both sides would get checked //false also this is how these work. true == true // true false == true // false false == false // true
10th Sep 2019, 1:13 PM
D_Stark
D_Stark - avatar
0
Thanks Mathews. Understood.
12th Sep 2019, 4:31 PM
Meetu Shringi
Meetu Shringi - avatar