How to use Logical Operators in Python
![how to use logical operators in python](https://pythonpoint.net/wp-content/uploads/2021/01/how-to-use-logical-operators-in-python-1024x576.jpg)
In this article, you will learn about different logical operators in Python, their syntax and how to use them with examples.
In Python, Logical operators are the and
, or
, not
operators.
and – True if both the operators are true, eg: x and y
or – True if either of the operands is true, eg: x or y
not – True if the operand is false(complementing the operand), eg: not x
Example:
x = True y = False print('x and y is ', x and y) print('x or y is ', x or y) print('not x is ', not x) print('not y is ', not y)
Output:
x and y is False x or y is True not x is False not y is True
Subscribe
Login
Please login to comment
0 Discussion