Comparison Operators

Comparison operators are ways to compare data

Example Code

# Comparison Operators

print(5 > 9)  # False
print(10 >= 9)  # True
print(5 < 9)  # True
print(10 <= 9)  # False

print(9 == 9)  # True
print(10 == 9)  # False

print(9 != 9)  # False
print(10 != 9)  # True

View code on GitHub.

Practice

Money

In Python syntax, what would you write to say you have at least $4.50?

💻 Template code

✅ Solution code

Compare X

You start with x = 10. Compare x with another number using a comparison operator such that if you print x (comparison operator) (another number), it prints False.

💻 Template code

✅ Solution code

Even