Sobes.tech
Junior — Middle

Can you list the main logical operators used in Python?

sobes.tech AI

Answer from AI

In Python, the main logical operators are:

  • and — logical AND, returns True if both operands are true.
  • or — logical OR, returns True if at least one operand is true.
  • not — logical negation, inverts the value.

Example:

x = True
y = False
print(x and y)  # False
print(x or y)   # True
print(not x)    # False