Search⌘ K
AI Features

Comparison Operators

Explore how to use Python comparison operators to evaluate values and understand identity operators to compare object memory locations. This lesson highlights floating-point comparison challenges and the best practices to handle them effectively.

Comparison operators can be used to compare values in mathematical terms. The precedence of comparison operator is same.

Symbol

Operator

>

Greater Than

<

Less Than

>=

Greater Than or Equal To

<=

Less Than or Equal To

==

Equal To

!=

Not Equal To

Output of comparison operators

The result of a comparison is always a bool. If the comparison is correct, the value of the bool will be True. Otherwise, its value will be False.

Try it yourself

...