Skip to content
techsnow

Python Basics

Comparison and Logical Operators

OperatorMeaning
==Equal
!=Not equal
> < >= <=Greater / less than
andBoth true
orAt least one true
notReverse
inIs inside a collection
isIs the same object (use for None)
age = 20
has_id = True
print(age >= 18 and has_id)   # True
print(age < 13 or has_id)     # True
print(not has_id)             # False
print("a" in "apple")         # True
print(10 < age < 30)          # True (chained comparison)