Page 59 - Touhpad Ai
P. 59
# 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
Assignment Operators
Assignment operators are used to assign values to variables. They combine the assignment operation with another
operation such as addition, subtraction, multiplication, etc.
Operator Description
= Assign the value of the right operand to the left operand
+= Adds right operand to left operand and assigns the result to left operand
-= Subtracts right operand from left operand and assigns the result to left operand
*= Multiplies left operand by right operand and assigns the result to left operand
/= Divides left operand by right operand and assigns the result to left operand
%= Computes modulus of left operand with right operand and assigns the result to left operand
//= Performs floor division on left operand by right operand and assigns the result to left operand
**= Raises left operand to the power of right operand and assigns the result to left operand
Program 7: To demonstrate the use of assignment operators
# Uses of Assignment Operators
# Assignment
x = 15
print("Assignment:", x)
# Addition assignment
x += 3
print("Addition Assignment:", x)
# Subtraction assignment
x -= 2
print("Subtraction Assignment:", x)
# Multiplication assignment
x *= 4
print("Multiplication Assignment:", x)
# Division assignment
x /= 2
Basic Concepts of Artificial Intelligence 57

