Skip to content

2.1.1 Comparison Operators (== != > < >= <=)

Comparison operators are used to compare two values and produce a boolean result.


Common Comparison Operators

Python supports the following comparison operators:

  • == : Equal to
  • != : Not equal to
  • > : Greater than
  • < : Less than
  • >= : Greater than or equal to
  • <= : Less than or equal to

Each comparison evaluates to either True or False.


Comparison Behavior

  • Comparisons can be performed on numbers, strings, and other data types
  • The result is always a boolean value
  • Comparison results are often used in conditional statements

📌 Note:
Do not confuse = (assignment) with == (comparison).