Skip to content
Justice Tech School

Operators

Comparison operators are == != < > <= >=. Logical operators are and, or and not. in checks membership and is checks that two names point to the same object. Assignment operators such as += change a variable in place.

Example
x = 5
print(x > 3 and x < 10)
print(not x == 5)
print("a" in "cat")
x += 2
print(x)
print(1 < x < 10)

Result

True
False
True
7
True

Exercise

Check that the letter is inside the word.

print("a"  "cat")

Quiz Test

What does 1 < x < 10 test?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.