+ 2

Can you better explain?

So right now im learning about boolean stuff like or, not, and, else, if. i understand most of whats going on like if and else. not is a bit confusing when used in some way but what i really dont get is this code right here... print(False == False or True) print(False == (False or True)) print((False == False) or True) it claims the 1st line is True, the second line is false and the final line is true. but i cant seem to wrap my mind around why. THANK YOU!

4th Apr 2017, 11:09 PM
Seth T
Seth T - avatar
16 Respuestas
+ 2
The first line is saying that False is equal to False and if the two things are the same then that is True. Its like saying 1 == 1 (yes one is equal to one which is true!). The second line is the funny one and its to do with the brackets it is asking whether false is false OR true because the brackets go around the two answers. It is like saying that, right is equal to right or wrong. which can not be true and so is false! Hope this helps
4th Apr 2017, 11:33 PM
Jason Hoffman
Jason Hoffman - avatar
+ 4
Actually they are both true. I'm kind of mean, because I constructed these in a way that your reasoning from above would fail. But I took the time to write a detailed explanation on how it works, so both of you are masters of boolean arithmetic in no time. https://code.sololearn.com/c48CtJEIe9LJ
5th Apr 2017, 11:16 AM
Tob
Tob - avatar
+ 3
You guys have some funny ideas. :D
5th Apr 2017, 1:07 AM
Tob
Tob - avatar
+ 3
Without looking it up beforehand, what outputs would you predict for print((False != False) or True), print(False == (False and True))?
5th Apr 2017, 1:12 AM
Tob
Tob - avatar
+ 3
(False or True) is not False. The value of that expression is True. The value of (False and True) is False. The reason is, that the or/and operator is defined that way.
5th Apr 2017, 4:53 PM
Tob
Tob - avatar
+ 3
Nope. Imagine that and is a function, that takes two parameters. It returns True, if both of the parameters are True. If one of them is False, it will return False. Read the code I posted very carefully. It was not written to confirm your ideas, but to help you get rid of your misconceptions. You can also read https://en.m.wikipedia.org/wiki/Truth_table Find logical conjunction in the binary operations section.
5th Apr 2017, 7:20 PM
Tob
Tob - avatar
+ 2
ahhhh i get it, so basically False == Flase which is true and the 2nd line is false because the brackets around False or True is basically saying false is false and true? which would false, right? and why would the 3rd be true?
4th Apr 2017, 11:42 PM
Seth T
Seth T - avatar
+ 2
Thats it!
4th Apr 2017, 11:58 PM
Jason Hoffman
Jason Hoffman - avatar
+ 2
the third is true because ( false is equal to false ) which is true! its all about the brackets.
5th Apr 2017, 12:03 AM
Jason Hoffman
Jason Hoffman - avatar
+ 1
thank you!
5th Apr 2017, 12:00 AM
Seth T
Seth T - avatar
+ 1
Ohhhh okay i get it, i just feel like the or true part at the end is kind of useless, i could simply put false == false and get the output True. seems like it mind <redacted> you for no reason 😂
5th Apr 2017, 12:04 AM
Seth T
Seth T - avatar
+ 1
your very welcome
5th Apr 2017, 12:06 AM
Jason Hoffman
Jason Hoffman - avatar
0
false and false
5th Apr 2017, 8:39 AM
Jason Hoffman
Jason Hoffman - avatar
0
Wow thanks for takimg the time to further explain tobi, it actually help by confirming a few thing, my only question that just occured to me which is why im so confused is why is (False or True) == False? and why would (False and True) == True?? why does the or/and change the answer?
5th Apr 2017, 2:34 PM
Seth T
Seth T - avatar
0
false and true is false because something CANT be both but something CAN either be False OR True?
5th Apr 2017, 4:55 PM
Seth T
Seth T - avatar
0
ohhh see that was a pretty simple way of saying it, in a way and is like false == true which would be false
5th Apr 2017, 7:22 PM
Seth T
Seth T - avatar