+ 13

Why>>> False == (False or True) False

Why the output of the code is false .it should be true because "or" take two arguments and if one of them is true the answer is true.

24th May 2019, 12:33 AM
Nishant Saini
Nishant Saini - avatar
12 odpowiedzi
+ 7
In 'or', if either or both side are true, the output is true, so in 'true or false' situation the output is true, and with the brackets on the first operation is the 'true or false' statement that will result true, and then the comparison will take place, and it would be 'false == true', which result 'false'... Try this, it may help you understand: Print(false == true or true) The beginning 'false == true' should output false, and there u got it, false or true, it will output true... Even if its: Print(6 == 8 or true) The second statement is true, so as we have said, in 'or' if either or both statements are true, then the output is true... try thinking it in that way, in case of 'or' you need to divide it to two statements, the left statement, and the right statement, if at least one of them output 'True', then the total output is true... so, for example, in case of:"false == 6 or false" the wrong way to calculate it would be: "false == 6 or false == false" but this: "false == 6, which output false" or false
26th May 2019, 7:05 AM
TheBobi321
TheBobi321 - avatar
+ 7
The or operator takes 2 conditional and returns True if either one of them is True. Because of this, the expression is the same thing as False == True, which is False.
24th May 2019, 12:43 AM
Faisal
Faisal - avatar
+ 5
But there is also second expression which is False==False And this is true.so it should be true
24th May 2019, 12:47 AM
Nishant Saini
Nishant Saini - avatar
24th May 2019, 12:52 AM
Nishant Saini
Nishant Saini - avatar
+ 5
(False or True) will result in True because the or will give True if at least one of the operands is True. Then, False == True will result in False. Read this way, it might help you: "is False the same thing as True?" No, right? So, it is False.
25th May 2019, 10:10 PM
r1c5
r1c5 - avatar
+ 3
Nishant Saini It seems to be only that 1 expression 🤷‍♂️ Is there another part of the code you left out?
24th May 2019, 12:50 AM
Faisal
Faisal - avatar
+ 3
here's a step by step solution False == (False or True) --------------------------------------- False or True >>> True --------------------------------------- False == (True) False == True >>> False
24th May 2019, 8:11 PM
Shen Bapiro
Shen Bapiro - avatar
+ 3
= 0 == (1||0) - bitwise OR = 0 == (1) = False
25th May 2019, 2:23 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 2
Remember your BEDMAS 😀. “==“ will go before “or” unless if there is brackets.
24th May 2019, 12:55 AM
Choe
Choe - avatar
+ 1
False == (False or True) = False == True = False False doesnt equal true, so its false.
24th May 2019, 12:47 AM
Choe
Choe - avatar
+ 1
Consider false as 0 and true as 1 then apply Boolean rule U will get your answer
25th May 2019, 2:56 PM
Joker
Joker - avatar