Page 176 - Ai_V3.0_c11_flipbook
P. 176
16 - 3 = 13
16 * 3 = 48
16 / 3 = 5.333333333333333
16 % 3 = 1
16 ** 3 = 4096
16 // 3 = 5
Comparison Operators
Comparison operators are used to compare two values and return a boolean result (True or False). They return True if the
comparison is true, otherwise return False. They are commonly used in conditional statements and loops.
Operator Description
== Checks if two operands are equal
!= Checks if two operands are not equal
> Checks if left operand is greater than right operand
< Checks if left operand is less than right operand
>= Checks if left operand is greater than or equal to right operand
<= Checks if left operand is less than or equal to right operand
Program 6: To demonstrate the use of comparison operators
# Uses of Comparison Operators
# Equal to
print("Equal to:", 10 == 5)
# Not equal to
print("Not equal to:", 10 != 5)
# Greater than
print("Greater than:", 10 > 5)
# Less than
print("Less than:", 10 < 5)
# Greater than or equal to
print("Greater than or equal to:", 10 >= 5)
# Less than or equal to
print("Less than or equal to:", 10 <= 5)
Output:
Equal to: False
Not equal to: True
Greater than: True
Less than: False
Greater than or equal to: True
Less than or equal to: False
174 Touchpad Artificial Intelligence (Ver. 3.0)-XI

