Definition:
The logical operator is a symbol that operates on operands. It specifies that the condition will be either true or false. The operands can be either variables or values. It checks the condition before executing the process.
Example:
a = 2
b = 2
if (a == b):
print("a is equal to b")
Output:
a is equal to b
There are some logical operators in Python as follows:
- AND Logical Operator (
and) - OR Logical Operator (
or) - NOT Logical Operator (
not)
