+ 2

Why does "print(False == (False or True))" return False?

Hi ! I'm doing the Python course on the operators and the booleans. I was specificly learning the operator - precedence. I don't understand why it returns False. In fact, "(True or False)" can be False and match with the "==". So why is it everytime False ? I would be nice to explain me where does my reasonning fail :) Thank you in advance ! Koast

26th Feb 2018, 6:28 PM
Koast
Koast - avatar
4 Respostas
+ 1
Thanks a lot maxcookmax ! The point i didn't get was that "(False or True)" returns True each time there is a True in the instruction. Koast
26th Feb 2018, 10:06 PM
Koast
Koast - avatar
+ 1
Does someone know the reason why False is overriden by True ?
26th Feb 2018, 10:10 PM
Koast
Koast - avatar
+ 1
It makes sense ! :D Thank a lot for your help. Very helpful ! Koast
27th Feb 2018, 9:22 PM
Koast
Koast - avatar
+ 1
Try to run this code i.e, print(False or True) you will get the output : True and then evaluate the expression print(False==True) ultimately the output will be False. Hope you find it helpful. Thank you :-)
2nd Mar 2018, 11:06 AM
Tufail
Tufail - avatar