Relational Operator

Last updated: Apr 12, 2026

Relational Operators

Relational operators are also called comparison operators. It performs a comparison between two values. It returns a boolean value True or False depending upon the result of the comparison. Python has the following six relational operators.

  1. < (Less than)
  2. > (Greater than)
  3. <= (Less than or equal to)
  4. >= (Greater than or equal to)
  5. == (Equal to)
  6. != (Not equal to)

Example:

x = 5
y = 2
print('x>y is', x>y)
print('x<y is', x<y)
print('x==y is', x==y)
print('x!=y is', x!=y)
print('x>=y is', x>=y)
print('x<=y is', x<=y)

Output:

x>y is True
x<y is False
x==y is False
x!=y is True
x>=y is True
x<=y is False