Comparison Operators

Before conditionals we must first learn to use comparison operators. Like logical operators, comparison operators return Booleans. Comparison operators compare two operands. One on the left and one on the right. If the comaprison is true, the operation returns true. If the comaparison is false, the operation returns false. There are a number of comparison operators available to use in Python. The following table describes them:

NameOperatorDescriptionExample
Equality==Check if operands are equal2 == 2
Inequality!=Check if operands are not equal4 != 2
Less Than<Check if left operand is less than right operand2 < 4
Less Than or Equal<=Check if left operand is less than or equal to right operand6 <= 7
Greater Than>Check if left operand is greater than right operand8 > 4
Greater Than or Equal>=Check if left operand is greater than or equla to right operand7 >= 3