Categories
Python Programming

Relational Operators

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:

  1. Equal To
  2. Not Equal To
  3. Greater Than
  4. Less Than
  5. Greater Than or Equal To
  6. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *