15 AnswersNew Answer
It is simply boolean algebra we have (1 = true, 0 = false) OR 1 0 -> 1 0 1 -> 1 1 1 -> 1 0 0 -> 0
False or True gives True (Boolean algebra) And False and True are not equal so it gives False as result
I didn't say I think it isn't false, I'm new to this and was asking for help as to why it's false. I just need a little clarification... I'm a little confused since it says "or"...
Vikash explains the reason very well. To add clarity, the == is a comparison operator. By the rule of order of operations parentheses are processed first. So the boolean expression (false or true) evaluates to True. Then the expression is evaluated as false == true. (Which reads "is false equal to true?) Which is False. Hence the result. When reading the code it's easy to make the logical error of assuming that if the left side of the comparison is false and the right side is false OR true then the result would be True. However, the order of operations and how boolean logic is processed has to be considered.
Fist of all false is 0 and true is 1 if 0 and 1 meet we get zero but if 1 and 1 meet we get one and if 0 and 0 meet we get 0 so this means that : false ==(false or true ) Is the same as saying. : 0 == ( 0 or 1 ) as you can see now that the can't be any possibility of having a true number since 0 and zero bring 0 and 0 and 1 bring 0 thank you hope it helps it only takes a second to upvote 😁
False == (False or True) In this expression python would first solve the comparison operator in bracket. => (False or True) is said to be True. Because the 'OR' operator search for the first truthy value, and if found it returns the value else 'False'. Now we have: =>False == True is False.
Reacy you can't apply associative property 😂 in this case
Thanks a lot, I have a much better understanding now... Special thanks to Emanuel Maliaño for breaking it down like that!
I appreciated Vikash as well and acknowledged Vikash in my 1st general thanks a lot. The special thanks was just because by Emanuel listing the example with the 1's & 0's like that it gave me a visual that made it a lot clearer than just the worded examples...
That's the full snippet from the lesson that confused me... Part of my misunderstanding is that the previous line without parenthesis returns as true, so I didn't fully grasp why the same sequence with parenthesis returned false.
The lessons don't give much details is the only negative of this app... They touch only the most basic of each matter, at least from what I've seen so far... Thankfully people like you guys in the community help bridge the information gaps by being so helpful!
Happy to help where I can! I agree, the explanations for some of the concepts is definitely lacking sometimes. Playing with code and asking questions when stuck is how I learn too!
Why do you think it isn't false?
>>> False == False or True True >>> False == (False or True) False >>> (False == False) or True True Johann Lynge