Relational operators are used for comparing the values. It either returns True or False according to the condition. These operators are also known as Comparison Operators. There are various Comparison operators, in this session, we will learn about their syntax and use with the help of an example.
Example
Comparison operators in Python
x = 10
y = 12
# Output: x > y is False
print('x > y is',x>y)
# Output: x < y is True
print('x < y is',x<y)
# Output: x == y is False
print('x == y is',x==y)
# Output: x != y is True
print('x != y is',x!=y)
# Output: x >= y is False
print('x >= y is',x>=y)
# Output: x <= y is True
print('x <= y is',x<=y)
Output
x > y is False
x < y is True
x == y is False
x != y is True
x >= y is False
x <= y is True