+ 2
When the programing is 1==(1 or 2) the output is true. But instead of 1 i gave 0, and 2 i gave 1 the output is false. Explain.
3 Réponses
+ 2
Python, hm?
True can be evaluated as 1, False as 0.
1 or 2 means that at least one of the Numbers has to evaluate as True. This is the case, because at least one is not zero.
So 1==(1 or 2) becomes 1==True, so 1 == 1.
Try this with zero now - you'll end up with 0 == 1.
0
Share the code, let the world see it so they can help you. Sorry, but I don't understand your explanation, it may help if you just share the code 👍
(Edit)
Please mention the language in Relevant Tags.
0
In condition u gave 1 == (1 or 2)
In this statement 1 is present but in ur another condition 1 ==(0 or 2) there is no 1 and the condition checking operator (==) check both side , so it returns false output for ur 2nd condition