+ 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!
16 odpowiedzi
+ 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
+ 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
+ 3
You guys have some funny ideas. :D
+ 3
Without looking it up beforehand, what outputs would you predict for
print((False != False) or True),
print(False == (False and True))?
+ 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.
+ 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.
+ 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?
+ 2
Thats it!
+ 2
the third is true because ( false is equal to false ) which is true! its all about the brackets.
+ 1
thank you!
+ 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 😂
+ 1
your very welcome
0
false and false
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?
0
false and true is false because something CANT be both but something CAN either be False OR True?
0
ohhh see that was a pretty simple way of saying it, in a way and is like false == true which would be false