Skip to Main Content

Python for Basic Data Analysis: 1.9 Comparison operators

Get started on your learning journey towards data science using Python. Equip yourself with practical skills in Python programming for the purpose of basic data manipulation and analysis.

Comparison operators 

Comparison operators 

We use comparison operators to compare between 2 or more values to return either a True or a False.

Operator Syntax Explanation
== x == y x is equal to y
!= x != y x is not equal to y
> x > y x is greater than y
< x < y x is less than y
>= x >= y x is greater than or equal to y
<= x <= y x is less than or equal to y

Click the triangle button to run the codes and see the output:

Exercises

Use the operators to solve for the following equation and print the outputs

1. 3 > 4
2. 3 == 4
3. 15 != 3