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.

### Aim: Write a program in python to do Arithmetical Operations

### 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: ')
# Add two numbers
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))
```

### Click below button to Download Source Code

### Output of Program:

**Explanation of Output**

Line 1 : Enter the first number is a output generated from the input of first number by program line num1=input(“Enter first number”)

Line 2: Enter the second number is a output generated from the input of second number by program line num2=input(“Enter second number”)

Line 3: sum of the number is calculated in program then printed by the command print()

Line 4: subtraction of the number is calculated in program then printed by the command print()

Line 5: multiply of the number is calculated in program then printed by the command print()

Line 6: Divisor of the number is calculated in program then printed by the command print()

Thank you for using post Python programs to do Arithmetical Operations. Below are some more programs. So, check them out.

- Python program to print “Hello Python” – CS Study
- Computer Science with Python Practical Book Solutions Class 11 Term -2 – CS Study
- Computer Science Practical file for class 12 Term-2 – CS Study