Back
+10 XP
Concept

Comparisons (==, !=, <, >)

Comparison operators test relationships and return `True` or `False`:

python
print(10 == 10)  # True (equal values)
print(10 != 5)   # True (not equal)
print(10 > 20)   # False

# 43. Comparisons (==, !=, <, >) Comparison operators test relationships and return `True` or `False`: ```python print(10 == 10) # True (equal values) print(10 != 5) # True (not equal) print(10 > 20) # False ``` Never confuse `==` (checking equality) with `=` (assigning a variable). Chained comparisons work out of the box: `1 < x < 10`.

Checkpoint

What does `5 == "5"` evaluate to in Python?

Practice

Write code comparing if `ammo > 0` for `ammo = 5`. Print the boolean result.

Terminal
01
Tap code blocks below to assemble
Available Blocks