Page 471 - ComputerScience_Class_11
P. 471
Program 4: To demonstrate the use of arithmetic operators.
Program 4.py
File Edit Format Run Options Window Help
# To assign value 10 to variable a
a = 10
# To assign value 3 to variable b
b = 3
# To add a and b
sum_result = a + b
print("Addition:", sum_result)
# To subtract b from a
sub_result = a - b
print("Subtraction:", sub_result)
# To multiply a and b
mul_result = a * b
print("Multiplication:", mul_result)
# To divide a by b
div_result = a / b
print("Division:", div_result)
# To find remainder when a is divided by b
mod_result = a % b
print("Modulus:", mod_result)
# To calculate a raised to the power of b
exp_result = a ** b
print("Exponentiation:", exp_result)
# To perform floor division of a by b
floor_div_result = a // b
print("Floor Division:", floor_div_result)
Output
Addition: 13
Subtraction: 7
Multiplication: 30
Division: 3.3333333333333335
Modulus: 1
Exponentiation: 1000
Floor Division: 3
Operators and Expressions 469

