Friday 4 December 2015

Logical Operators in python

Following are the logical operators supported by python.

Operator
Description
and
‘a and b’ returns true if both a, b are true. Else false.
or
‘a or b’ return false, if both a and b are false, else true.
not
‘not a’ Returns True if a is false, true otherwise



>>> a=bool(0)
>>> b=bool(1)
>>> 
>>> a
False
>>> b
True
>>> 
>>> a and b
False
>>> 
>>> a or b
True
>>> 
>>> not a
True
>>> 
>>> not (a and b)
True
>>> 
>>> not ( a or b)
False






Previous                                                 Next                                                 Home

No comments:

Post a Comment