Relational operators in Python 3

Relational operators in Python 3

Relational operators are also known as comparison operators.
They are used to perform comparison between values in a program.
The result of relational expression is always True or False. Various relational Operators in Python are:

Operator Purpose Example
<
(Less Than)
To check whether a value is smaller than another value. 3<10
returns True
10<3
returns False
<=
(Less than equal to)
To check whether a value is smaller than or equal another value. 3<=10
returns True
10<=3
returns False
3<=3
returns True
>
(Greater than)
To check whether a value is larger than another value. 10>3
returns True
3>10
returns False
>=
(Greater than equal to)
To check whether a value is larger than or equal to another value. 10>=3
returns True
3>10
returns False
3>=3
returns True
= =
(Equal to)
To check whether a value is equal to another value. 10==3
returns False
3==3
returns True
!=
(Not equal to)
To check whether a value is not equal to another value. 10!=3
returns True
10!=10
returns False

Spread the love
Lesson tags: binary operators of python, rellational operators of python
Back to: Python Programming Tutorial
Spread the love