Python Tutorials · Python Operators
Comparison Operators
Learn all about Comparison Operators in this comprehensive tutorial.
5 min read beginner
- •Comparison operators are used to compare two values:
- •Comparison operators return True or False based on the comparison:
- •Python allows you to chain comparison operators:
Comparison Operators
Comparison operators are used to compare two values:
| Operator | Name | Example | Try it |
|---|---|---|---|
| == | Equal | x == y | Try it » |
| != | Not equal | x != y | Try it » |
| > | Greater than | x > y | Try it » |
| < | Less than | x < y | Try it » |
| >= | Greater than or equal to | x >= y | Try it » |
| <= | Less than or equal to | x <= y | Try it » |
Examples
Comparison operators return True or False based on the comparison:
python
Chaining Comparison Operators
Python allows you to chain comparison operators:
python
Module quiz
2 questions1
Which of the following is true about Comparison Operators?
2
What is the most common pitfall when working with Comparison Operators?
Answer all questions to submit.