Python - Relational Operators
Python provides operators that can be used to check the relationship between values or values within variables also known as operands.
All relational operators, less than(
<), less than or equal to(
<=), greater than(
>), greater than and equal to(
>=) gives resultant value in boolean i.e either
false after evaluation.
In this article, you will find Relational operators provided by python.
|Less than or equal to|
|Greater than or equal to|
- All of these relational operators are binary operators.
- All these relational operators also follow the general structure of
Operand, meaning that an operator is always surrounded by two operands.
- For example, an expression
x >= yis a binary operation, where x and y are two operands and >= is an operator. If value of
xis greater than
yyou will get
Trueas value else
- The resultant value for relational expression will always be boolean(
# create variables a = 10 b = 12 # value of a and b print('Value of a is', a, 'and b is', b) # > operator print(a > b) # false # < operator print(a < b) # true # >= operator print(a >= b) # false # <= operator print(a <= b) # true
Hope you like this!
Keep helping and happy 😄 coding