Relational Operators in Python


==
Equal to
x == y
if x equal to y True otherwise False
!=
Not Equal to
x != y
if x equals not b True otherwise False
> 
Greater than
x > y
if x Greater than y True otherwise False
< 
Less than
x < y
True if x less than y otherwise False
>=
Greater than or equal to
x >= y
if x greater than or equal to y True  otherwise False
<=
Less than or equal to
x <= y
if x less than or equal to y True otherwise False


Equal to(==) Relational Operator 

Source Code :


x = 5

y = 6

print(x == y)

print(x == y)

print((x<y) == (y>x))

Output :
False 
True
True



Not Equal to(!=) Relational Operator 

Source Code :

x = 5

y = 6

print(x != y)
print(x != 5)
print((x<y) != (y<x))

Output :
True 
False True



Less than(<) Relational Operator 

Source Code :

x = 5

y = 6

print(x < y)
print(x > y)

Output :
True 
False



Greater than(>) Relational Operator 

Source Code :

x =

y =

print(x > y)
print(x < y)

Output :
False 
True



Less than or Equal to(<=) Relational Operator 

Source Code :

x =

y =

z =

print(x <= y)
print(y <= z)

Output :
True 
True



Greater than or Equal to(>=) Relational Operator 

Source Code :

x =

y =

z =

print(x >= y)
print(x >= z)

Output :
False 
True