Logical Operator

Last updated: Apr 12, 2026

Logical Operators

Logical operators are useful when checking if a condition is true or not. Python has three logical operators. All logical operators return a boolean value True or False depending on the condition in which it is used.

Operator Description Example
and (Logical and) True if both the operands are True a and b
or (Logical or) True if either of the operands is True a or b
not (Logical not) True if the operand is False not a

Example:

a = True
b = False
 
print('a and b is', a and b)   # False — both must be True
print('a or b is', a or b)     # True  — at least one is True
print('not a is', not a)       # False — reverses True to False

Output:

a and b is False
a or b is True
not a is False