and: Returns True if both statements are true.
Syntax: statement1 and statement2
x = 5 y = 10 print(x > 0 and y < 15) # Output: True
or: Returns True if at least one of the statements is true.
Syntax: statement1 or statement2
x = 5 y = 20 print(x > 0 or y < 15) # Output: True
not: Returns True if the statement is false.
Syntax: not statement
x = 5 print(not(x > 0)) # Output: False
Python program that demonstrates the use of Logical operators:
x = 10 y = 20 z = 30 # Using 'and' if x < y and y < z: print("Both conditions are true") # Using 'or' if x > y or y < z: print("At least one condition is true") # Using 'not' if not(x > z): print("The condition is false")