Here the code.
a = False
if a == True or True:
print "Hell yeah,I'm genius"
else:
print "shit,I am a fool"
Output is 'Hell yeah,I'm genius
'
Here the code.
a = False
if a == True or True:
print "Hell yeah,I'm genius"
else:
print "shit,I am a fool"
Output is 'Hell yeah,I'm genius
'
a ==True or True
Consider True is 1 and 0 is False.
Since a is set to False (a=False in first statement of code), the first part 'a==True' i.e. 0 ==1 will return 0 (False).
Then remaining will be False or True since 'a==True' is False. So it will be like 0 or 1 (False or True).
We know that
So in your case, 0 OR 1 will result to 1 i.e. True.
Summary :
a == True or True => False or True => True
That's why "Hell yeah,I'm genius" will be printed.
Anything True , it will run that section ...
if True:
print "Hell yeah,I'm genius"
else:
print "shit,I am a fool"
This one also returns "Hell yeah,I'm genius"