Operator precedence | SoloLearn: Learn to code for FREE!

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.

9/10/2019 8:02:36 AM

Meetu Shringi

3 Answers

New Answer

+4

https://code.sololearn.com/WSJyHqt8xSIE/?ref=app

+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

0

Thanks Mathews. Understood.