لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

Lesson 14: Logical operators In Python

Logical operators In Python are used to combine conditional statements.

Operator Description Example
and Returns True if both statements are true x < 5 and x < 10

Illustration
x = 6
print(x > 3 and x < 10)
Output: Returns True because 6 is greater than 3 AND 6 is less than 10

Operator Description Example
or Returns True if one of the statements is true x < 5 or x < 4

Illustration
x = 6
print(x > 3 or x < 4)
Output: Returns True because one of the conditions are true (6 is greater than 3, but 6 is not less than 4)

Operator Description Example
not Reverse the result, returns False if the result is true not(x < 5 and x < 10)

Illustration
x = 5
print(not(x > 3 or x < 4))
Output: Returns True because one of the conditions are true (5 is greater than 3, but 5 is not less than 4)