Python – Comparison Operators
Comparison operators are used to compare two values.
Equal (==
): Checks if two operands are equal.
print(a == b) # Output: False
Not Equal (!=
): Checks if two operands are not equal.
print(a != b) # Output: True
Greater Than (>
): Checks if the first operand is greater than the second.
print(a > b) # Output: True
Less Than (<
): Checks if the first operand is less than the second.
print(a < b) # Output: False
Greater Than or Equal To (>=
): Checks if the first operand is greater than or equal to the second.
print(a >= b) # Output: True
Less Than or Equal To (<=
): Checks if the first operand is less than or equal to the second.
print(a <= b) # Output: False