Page 72 - TP_Prime_V2.2_Class7
P. 72
Relational Operators
We have studied about the arithmetic operators; another category is the relational
operators. Relational operators are used to compare the values of the operands and return
the result as true or false. Python provides the following relational operators:
Operator Name Description (x=8 and y=6) Output
Example
Prime (Ver. 2.2)-VII == Not equal It checks if the values of two x == y FALSE MORE ON PYTHON
It checks if the values of two
Equal
operands are equal or not. If yes, then
the condition becomes true.
x != y
!=
TRUE
operands are equal or not. If the
values are not equal, then the condition
becomes true.
> Greater It checks if the value of left operand x > y TRUE
70 than is greater than the value of right 71
operand. If yes, then the condition
becomes true.
< Less than It checks if the value of left operand x < y FALSE
is less than the value of right operand.
If yes, then the condition becomes
true.
>= Greater It checks if the value of left operand x >= y TRUE
than or is greater than or equal to the value
equal to of right operand. If yes, then the
condition becomes true.
<= Less than It checks if the value of left operand x <= y FALSE
or equal is less than or equal to the value
to of right operand. If yes, then the
condition becomes true.
Let us use them in a program:
Using Relational Operators

