In this article we will be looking in to python program that declares 10 variables and use all the mathematical operations.
For Example: Addition, Subtraction, Multiplication, Division and Power Of X
#1 Python Program to declare 10 variables and use all the mathematical operations
number1 = 10
number2 = 66
number3 = 90
number4 = 2
number5 = 45
number6 = 78
number7 = 887
number8 = 76
number9 = 7698
number10 = 20
print("Addition of %d + %d is %d" % (number1, number2, number1 + number2))
print("Subtraction of %d - %d is %d" % (number3, number4, number3 - number4))
print("Multiplication of %d x %d is %d" % (number5, number6, number5 * number6))
print("Quotient of %d / %d is %f" % (number7, number8, number7 / number8))
print("Floor Division of %d // %d is %f" % (number7, number8, number7 // number8))
print("Reminder of %d / %d is %f" % (number7, number8, number7 % number8))
print("Exponential of %d raised to %d is %d" % (number9, number10, number9 ** number10))
Output:
> python main.py
Addition of 10 + 66 is 76
Subtraction of 90 - 2 is 88
Multiplication of 45 x 78 is 3510
Quotient of 887 / 76 is 11.671053
Floor Division of 887 / 76 is 11
Reminder of 887 / 76 is 51
Exponential of 7698 raised to 20 is 534020753437622317433008298196168934138641826879674347969538744275380995096576
Program in Image Format
In the above program I have declared 10 variables and assigned the random numbers. After assigning numbers I am trying addition, subtraction, multiplication, division, floor division, reminder and exponential.
Above program is classic example of python arithmetic operation.
Video Explanation
#2 - Python Program with added Negation
Lets work on same program by changing the variable names from number to variable, have added extra operation i.e, negation in below program.
variable1 = 10
variable2 = 66
variable3 = 90
variable4 = 2
variable5 = 45
variable6 = 78
variable7 = 887
variable8 = 76
variable9 = 7698
variable10 = 20
print("Negation of %d is %d" %(variable1, -variable1))
print("Addition of %d + %d is %d" %(variable1, variable2, variable1 + variable2))
print("Subtraction of %d - %d is %d" %(variable3, variable4, variable3 - variable4))
print("Multiplication of %d x %d is %d" %(variable5, variable6, variable5 * variable6))
print("Quotient of %d / %d is %f" %(variable7, variable8, variable7 / variable8))
print("Floor Division of %d // %d is %f" %(variable7, variable8, variable7 // variable8))
print("Reminder of %d / %d is %f" %(variable7, variable8, variable7 % variable8))
print("Exponential of %d raised to %d is %d" %(variable9, variable10, variable9 ** variable10))
OUTPUT:
Negation of 10 is -10
Addition of 10 + 66 is 76
Subtraction of 90 - 2 is 88
Multiplication of 45 x 78 is 3510
Quotient of 887 / 76 is 11.671053
Floor Division of 887 // 76 is 11
Reminder of 887 / 76 is 51
Exponential of 7698 raised to 20 is 534020753437622317433008298196168934138641826879674347969538744275380995096576
0 Comments