Loading...
Python

Logical Operator

Logical Operators are and, or, not

For Boolean Types:

and ==> If both arguments are True then the result is True
or ==>If one argument is True then the result is True
not==> the result will be complement

True and False ==> False
True or False ==> True
not False ==> True

For Non-Boolean Type:

0 means False
non-zero means True
Empty string is always treated as False

x and y:

==> if x is evaluates to False return x otherwise return y

Example:

10 and 20
0 and 20

If first argument is zero then result is zero or else result is y

Leave a Reply

Your email address will not be published. Required fields are marked *