NEPTUNIAN ANALYTICS

Booleans

bool is a data type in Python that has two values True or False. In programming it is often essential to know if an expression is true or false. As is illustrated below.

Comparison Operators

Comparison operators are a kind of operator that can compare two values. For example, is 15 greater than 7? Python's comparison operators are shown below

Operations Operator Example Output
Equal to == 5 == 5 True
Not equal to != 5 != 5 False
Greater than > 4 > 5 False
Greater than or equal to >= 7 >= 7 True
Less than < 2 < 4 True
Less than or equal to <= 4 <= 3 False

Is 45 greater than 74?

To evaluate if 45 is greater than 74, enter the below code into a code editor:

45 > 74

Output

False

In the code above we asked if 45 is greater than 74. Since 45 is smaller than 74 the output was False.

Try performing some other comparisons using the guidelines above. For example, try assigning two new different values to two different variables and then comparing them.