Operators: Comparison, Logical, Membership
Compare with == != < >, combine with and, or, not, test membership with in and identity with is. Comparisons can be chained.
Example
x = 5
print(1 < x < 10, x > 3 and x < 4, not x == 5)
print(3 in [1, 2, 3], "a" in "cat")Result
True False False True True
Exercise
Chained check.
print(1 x < 10)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.