Page 118 - 2622_Delhi Police Public School_C-6
P. 118
Relational Operator
Relational operators are used to compare the value of the two operands and return True or False
accordingly. The relational operators are described in the following table:
Operator Name Description Example Output
(x=8 and y=6)
== Equal It checks if the values of two operands are equal x == y False
or not. If yes, then the condition becomes true.
!= Not equal It checks if the values of two operands are x != y True
equal or not. If the values are not equal, then
the condition becomes true.
> Greater It checks if the value of the left operand is x > y True
than greater than the value of the right operand. If
yes, then the condition becomes true.
< Less than It checks if the value of the left operand is less x < y False
than the value of the right operand. If yes, then
the condition becomes true.
>= Greater It checks if the value of the left operand is greater x >= y True
than or than or equal to the value of the right operand.
equal to If yes, then the condition becomes true.
<= Less than It checks if the value of the left operand is less x <= y False
or equal to than or equal to the value of the right operand.
If yes, then the condition becomes true.
Program 4: To show all the relational operators’ functions
Program4.py
File Edit Format Run Options Window Help
#Program to perform Relational Operators
a = 11
b = 32
#Check if a is greater than b
print (a > b)
#Check if a is less than b
print (a < b)
#Check if a is equal to b
print (a == b) Output
#Check if a is not equal to b
False
print (a != b)
True
#Check if a is greater than equal to b
False
print (a >= b)
True
#Check if a is ess than equal to b
False
print (a <= b)
True
116 Premium Edition-VI

