Skip to Main Content
It looks like you're using Internet Explorer 11 or older. This website works best with modern browsers such as the latest versions of Chrome, Firefox, Safari, and Edge. If you continue with this browser, you may see unexpected results.

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:


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

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