what are six relational operators used in python?

1 answer

In Python, relational operators (also known as comparison operators) are used to compare two values. Here are six common relational operators:

  1. Equal to (==): Checks if two values are equal.

    a == b
    
  2. Not equal to (!=): Checks if two values are not equal.

    a != b
    
  3. Greater than (>): Checks if the left value is greater than the right value.

    a > b
    
  4. Less than (<): Checks if the left value is less than the right value.

    a < b
    
  5. Greater than or equal to (>=): Checks if the left value is greater than or equal to the right value.

    a >= b
    
  6. Less than or equal to (<=): Checks if the left value is less than or equal to the right value.

    a <= b
    

These operators return a Boolean value (True or False) based on the comparison.