Loading lesson path
Comparison operators are used to compare two values:
== Equal x == y Try it » != Not equal x != y Try it » >
Formula
Greater than x > yTry it » <
Formula
Less than x < yTry it » >= Greater than or equal to x >= y Try it » <= Less than or equal to x <= y Try it »
Example x = 5 y = 3 print(x == y)
print(x != y)
print(x > y)
print(x < y)
print(x >= y)
print(x <= y)Python allows you to chain comparison operators:
Example x = 5 print(1 < x < 10)
print(1 < x and x < 10)