Python Relational Operators:
We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it. |
(1) These operators are also called Comparison Operators. These operators are used to do comparisons. In some expressions, it is required to compare the variables or constants. These operators always result in a Boolean value (True or False). In Python, the non-zero value is treated as true and the zero value is treated as false.
Operator | Name |
---|---|
== | Equal |
!= | Not Equal |
> | Greater Than |
< | Less Than |
>= | Greater Than or Equal To |
<= | Less Than or Equal To |
(2) Example of Equal Operator.


(3) Example of Not Equal Operator.


(4) Example of Greater Than and Less Than Operator.


(5) Example of Greater Than or Equal To and Less Than or Equal To Operator.
- Greater Than or Equal To (>=)- If the value of the left-side operand is greater than or equal to the value of the right-side operand, then the condition is True, otherwise it is False.
- Less Than or Equal To (<=)- If the value of the left operand is less than or equal to the value of the right operand, then is True otherwise it is False.


Comments (No)