There are 3 logical operators available in Python.
and, or , not.
3>4 and 5>6 #False
3 or 4 #3
3 and 4 #4
Empty string is treated as False.
Non empty strings are treated as true.
The important points to be noted are as follows:
and, or , not.
and | a>b and a<c | Both true then true |
or | a>b and a<c | Any one true then true |
not | not a>b | Invert the result |
3>4 and 5>6 #False
3 or 4 #3
3 and 4 #4
Empty string is treated as False.
Non empty strings are treated as true.
The important points to be noted are as follows:
- x and y: If x and y are not boolean then result is not boolean. If x is False then result is x otherwise result is y.
- x or y: If x and y are not boolean here,then result is also not boolean. If x is False result is y otherwise result is x. eg 0 or 5 result is 5
Be First to Post Comment !
Post a Comment