Comparison Operators
Operator
Meaning
Example
Example 1: Comparison operators in Python
x = 10
y = 12
# Output: x > y is False
print(f'x > y is {x>y}')
# Output: x < y is True
print(f'x < y is {x<y}')
# Output: x == y is False
print(f'x == y is {x==y}')
# Output: x != y is True
print(f'x != y is {x!=y}')
# Output: x >= y is False
print(f'x >= y is {x>=y}')
# Output: x <= y is True
print(f'x <= y is {x<=y}')Output:
Greater than
Less than
Equal to
Not equal to
Greater than or equal to
Less than or equal to
Last updated