Less than Sign
The Less Than Operator returns True if the left operand is less than the right operand otherwise it returns False.
Syntax: a < b
Example: In this code, we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used less than operator to check if a variable is less than the other.
a = 9
b = 5
# Output
print(a < b)
print(b < a)
Output:
False
True
Comparison Operators in Python
The Python operators can be used with various data types, including numbers, strings, booleans, and more. In Python, comparison operators are used to compare the values of two operands (elements being compared). When comparing strings, the comparison is based on the alphabetical order of their characters (lexicographic order).
Be cautious when comparing floating-point numbers due to potential precision issues. Consider using a small tolerance value for comparisons instead of strict equality.