🟰 Comparison Operators
5th Grade 💻 Coding
Comparison operators are symbols that compare two values and give back true or false — for example greater than, less than and equal to.
Python has six comparison operators: > greater than, < less than, >= greater than or equal to, <= less than or equal to, == equal to, and != not equal to. Every comparison like this is a question, and the answer is True or False.
The most common mix-up: a single equals sign (=) stores a value in a variable, while two (==) ask whether two values are equal. You can compare text too: "cat" == "cat" is True. In Scratch, the comparison blocks are the green ones in the Operators category.
For example
score >= 100checks whether you’ve reached 100 points or more.- The
!=sign is handy for checking:answer != "yes"means “the answer is not yes.” - In a guessing game you check
guess == secretto see if the guess is right, andguess < secretto say “Higher.”
📌 Remember: One = stores. Two == ask.
Quick quiz
What does == mean in Python?
What does != mean?
What does 3 >= 3 give back?