Use comparison operators to compare two values.
These operators return either True or False.
They are:
==: Equal!=: Not equal>: Greater than<: Less than>=: Greater than or equal to<=: Less than or equal to
Let’s see a program that shows how each of them is used.
x = 5
y = 2
print('Equal:', x == y)
print('Not equal:', x != y)
print('Greater than:', x > y)
print('Less than:', x < y)
print('Greater than or equal to:', x >= y)
print('Less than or equal to:', x <= y)The output is:
Equal: False
Not equal: True
Greater than: True
Less than: False
Greater than or equal to: True
Less than or equal to: False