Pythondex

Tutorial

Comparison Operators in Python

Comparison operators in Python are used to compare two values. The result is always a boolean: True or False.

Common Comparison Operators

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

Examples

Using Comparisons in Conditions

These operators are often used in if statements and loops to control the flow of a program based on conditions.