Python Comparison Operators

What are operators and operands? Let’s explain with a simple example: 10 > 5. Here, 10 and 5 are the operands, and > is the operator.

Consider the variables a = 10 and b = 5.

OperatorDescriptionExampleResult
==Checks if operand values are equal. If they are, the condition is truea == bFalse
!=Checks if operand values are not equal. If they are not equal, the condition is truea != bTrue
>Checks if the left operand is greater than the right operand. If it is, the condition is truea > bTrue
<Checks if the left operand is less than the right operand. If it is, the condition is truea < bFalse
>=Checks if the left operand is greater than or equal to the right operand. If it is, the condition is truea >= bTrue
<=Checks if the left operand is less than or equal to the right operand. If it is, the condition is truea <= bFalse