Please explain this | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

21st Apr 2020, 11:04 AM
Eco Fico
Eco Fico - avatar
8 Answers
+ 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.
21st Apr 2020, 11:27 AM
andriy kan
andriy kan - avatar
+ 2
RajLaxmi nope!! I understood
21st Apr 2020, 3:06 PM
Eco Fico
Eco Fico - avatar
+ 1
Eco Fico Excellent and keep it up.
21st Apr 2020, 5:08 PM
Raj Laxmi Verma
Raj Laxmi Verma - avatar
0
Add parentheses will make it more understandable. It is equivalent to (False == False) or True
21st Apr 2020, 11:07 AM
你知道規則,我也是
你知道規則,我也是 - avatar
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.
21st Apr 2020, 11:12 AM
Slick
Slick - avatar
0
Eco Fico r u still in trouble????
21st Apr 2020, 11:28 AM
Raj Laxmi Verma
Raj Laxmi Verma - avatar
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
21st Apr 2020, 2:43 PM
madeline
madeline - avatar
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.
22nd Apr 2020, 11:26 AM
Krishna Suryawanshi
Krishna Suryawanshi - avatar