Module 2

Comparison operators

The symbols Python uses to compare values.

Comparing values

Python uses comparison operators to compare values. The most common are: equal (==), not equal (!=), greater than (>), less than (<), greater or equal (>=), and less or equal (<=).

Python
print(5 == 5)
print(5 == 3)
print(5 != 3)
print(5 >= 5)
True False True True
A common mistake

Use two equals signs (==) to check equality. A single equals (=) assigns a value to a variable. Mixing them up is one of the most common beginner errors.

Your task

Compare values

  • Check whether 10 is greater than 5 and print the result.