Why does "print(False == (False or True))" return False? | SoloLearn: Learn to code for FREE!

+1

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

2/26/2018 6:28:24 PM

Koast

7 Answers

New Answer

+1

or is either one has to be true so it can return true, else its false

+3

false or true returns true. false == true is false

+2

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

+2

Happy to help! What I think the reason why is because true (1) and false (0) are one byte. 1 is on 0 is off, no electricity flows when its 0, or false, so a true is worth more. Hopefully that makes sense lol

+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 :-)