Python program to do Arithmetical Operations

Python program to do Arithmetical Operations. This program is a must for python beginners. This programs does mathematical calculation that we define in the program and print the answer. Download source code.

How the Program will works ?

We will be taking input of two numbers through the input command. Integer type for which we are not requiring to write any keyword because as default the value of the input () function is integer type. So, After getting input of the two numbers we will be carrying out calculation of 4 main arithmetic operation like sum, subtraction, multiplication and division. After carrying out calculation the variables containing the values will be printing in different line to line print statements. So, The printing statements which is a statement inbuilt in the python environment is directly used. So, This program will be writing in scripting mode as it requires multiple statement.

Source Code (Python)

``````# Store input numbers:
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')

sum = float(num1) + float(num2)
# Subtract two numbers
min = float(num1) - float(num2)
# Multiply two numbers
mul = float(num1) * float(num2)
#Divide two numbers
div = float(num1) / float(num2)
# Display the sum
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))

# Display the subtraction
print('The subtraction of {0} and {1} is {2}'.format(num1, num2, min))
# Display the multiplication
print('The multiplication of {0} and {1} is {2}'.format(num1, num2, mul))
# Display the division
print('The division of {0} and {1} is {2}'.format(num1, num2, div))  ``````