Relational operators check the relationship between two operands. They return true if the comparison or relation is true otherwise it will return false.
There are six comparison operators in the Python programming language. They are:
- Equal To
- Not Equal To
- Greater Than
- Less Than
- Greater Than or Equal To
- Less Than or Equal To
Equal To (==)
The equal to operator is represented by the double equal sign (==) in the Python programming language. The single equal sign (=) is used for assignment in the Python programming language.
The equal to symbol checks if two operands are equal.
Not Equal To (!=)
This is the opposite of the equal to symbol. It checks if the two operands are not equal.
Greater Than (>)
This checks if the left operand is greater than the right operand.
Less Than (<)
The less than operator is the opposite of the greater than operator. It checks if the operand on the left is less than the operand on the right.
Greater Than or Equal To (>=)
Checks if the left hand operand is either greater or equal to the right hand operand.
Less Than or Equal To (<=)
Checks if the left hand operand is either less or equal to the right hand operand.
Relational operators allow the programmer to define conditions in their code based on the relationship between two variables.