Python: Logical Operators

Profile picture for user devanshi.srivastava
Submitted by devanshi.srivastava on

Logical Operators are used to perform logical operation between two given conditional statements.

OperatorDescriptionSyntax
andIt will return True, if both statements are true.a and b
orIt will return True, if one of the statements is true.a or b
notIt reverse the result, returns False if the result is true.not a

Example:

a = 5
print(a < 6 and a < 7)
print(a > 6 and a < 8)
print(not(a < 6))

Output:

True
False
False
Tags