🧩Comparison Operator
Also known as Relational Operator
A sign like ==, > or != that compares two values and answers true or false.
Think of it like
Think of it like a kitchen scale with two pans. It tells you which side is heavier, or if they match.
Example
A cinema site checks age >= 13 before it shows a teen film. Jack is 12, so the answer is False.
Why it matters
Every decision in code starts with a comparison. They are the questions an if asks.
Definition
Example code
python
>>> age = 12
>>> age >= 13
False
>>> age == 12
TrueCommon mistake
Key takeaways
- 1Two values in. It looks at a left and a right.
- 2True or false out. The answer is always a boolean.
- 3Two equals signs. == compares; = stores.