Comparison operators are ways to compare data
> means "greater than"
>= means "at least"
< means "less than"
<= means "no more than"
== means "equal to"
<aside>
💡 Don't confuse == with =. = is for assignment while == is for checking equality
</aside>
!= means "not equal to"
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.
In Python syntax, what would you write to say you have at least $4.50?
💻 Template code
✅ Solution code
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