why True==3<5 is False | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why True==3<5 is False

2nd Oct 2016, 2:47 AM
dhvvfh
3 Answers
+ 4
Look at operator precedence and short-circuit boolean, through 'comparisons': https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not Here's a hint (add to Ryne's answer): >>> True==3 False >>> 3<5 True >>> True==3<5 False >>> (True==3)<5 True >>> True==(3<5) True >>> False==True False >>> False==False<True True >>> False==(False<True) False
2nd Oct 2016, 4:43 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
I think I figured it out, but this might just be a coincidence. True==3<5 is the same as writing True==3 and 3<5. In this case, since True==3 is not true, the whole and statement will be false.
2nd Oct 2016, 3:55 AM
Ryne
Ryne - avatar
0
That's weird. If anyone knows, let me know too
2nd Oct 2016, 3:23 AM
Ryne
Ryne - avatar