0
Please explain this
I'm 13 and I'm striving to learn python But why, False == False or true >>> True please explain this logic
8 Respuestas
+ 3
You can rewrite the expression like
(Flase == False) or True
== operator has higher precedence than 'or' operator, so
False == False will be evaluated first.
Its result is True as both operands are the same (even they are False, zero is equal to zero)
Then operatoror 'or' is evaluated. Its first operand is the result of (False == False) which is True.
As first operand of 'or' is True, its value is returned as the result of 'or' operator.
So result is True.
+ 2
RajLaxmi nope!! I understood
+ 1
Eco Fico Excellent and keep it up.
0
Add parentheses will make it more understandable. It is equivalent to (False == False) or True
0
Think about it like this:
False == (False OR True)
True
#OR being the keyword
#OR means "if the starting value is #equal to either one of these, return #True.
With that logic...
False == (True AND False)
False
#This one is literally checking if the #starting value is True AND False
#This is impossible because #something cant be True AND False at #the same time.
0
Eco Fico r u still in trouble????
0
or means it could equal either false or true so since it equals false, which is one of the two things it could equal, it is true.
keep working with logic and it will eventually make sense
0
According to the precedence of operators, it is first going to solve the boolean expression of False==False which is always going to be true and by the principle of 'or', True or True will be true. Hence the overall output of the code is True.
I hope it helps you.
Regards.