0

What is the OR. for

31st Oct 2017, 3:50 PM
Edian Bryan
Edian Bryan - avatar
2 Answers
+ 2
With OR you check the operands from left and right. n = 25 if n < 0 or n > 100: print("%d is out of range [0-100]" % n) else: print("%d is between [0-100]" % n) if the left operand returns True, then the right is not checked, and the code in the block is executed. If it's False, but the right is True, the code is executed. So, only if both operands are False, the code in the block is not executed. Let 1 is True, 0 is False, then: OR: 0 or 0 - 0 0 or 1 - 1 1 or 0 - 1 1 or 1 - 1 AND: 0 and 0 - 0 0 and 1 - 0 1 and 0 - 0 1 and 1 - 1 if n >= 0 and n <= 100: print("%d is in range [0-100]" % n) else: print("%d is out of range [0-100]" % n)
31st Oct 2017, 4:37 PM
Boris Batinkov
Boris Batinkov - avatar
0
OR means?? what's your doubt?
31st Oct 2017, 4:19 PM
sayan chandra
sayan chandra - avatar