+ 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
4 odpowiedzi
+ 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
+ 1
Does someone know the reason why False is overriden by True ?
+ 1
It makes sense ! :D
Thank a lot for your help. Very helpful !
Koast
+ 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 :-)