2.3.2 Comparison Operators
Python Programming
Comparison operators are used to compare two values or expressions. They determine the relational logic between them, such as equality, inequality, greater than, less than, and so on. These operators return a boolean value (True or False) based on the comparison result. Here's a Python program that demonstrates the usage of all comparison operators.
python
# Define variables
x, y = 10, 5
# Greater than
print(x, ">", y, "=", x > y) # Output: 10 > 5 = True
# Less than
print(x, "<", y, "=", x < y) # Output: 10 < 5 = False
# Equal to