Python program of arithmetical operations
In this program, we will code the following four basic arithmetical operations.
- Addition
- Subtraction
- Multiplication
- Division
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # Store input numbers: FirstNumber = input('Enter first number: ') SecondNumber = input('Enter second number: ') # Adding two numbers Result = float(FirstNumber) + float(SecondNumber) # Subtracting two numbers min = float( FirstNumber) - float(SecondNumber) # Multiply two numbers mul = float(FirstNumber) * float(SecondNumber) #Dividing two numbers div = float(FirstNumber ) / float(SecondNumber) # Displaying the sum print('The sum of {0} and {1} is {2}'.format(FirstNumber, SecondNumber, Result)) # Displaying the subtraction print('The subtraction of {0} and {1} is {2}'.format(FirstNumber, SecondNumber, min)) # Display the multiplication print('The multiplication of {0} and {1} is {2}'.format(FirstNumber, SecondNumber, mul)) # Displaying the division print('The division of {0} and {1} is {2}'.format(FirstNumber, SecondNumber, div)) |
Output
Enter first number: 4
Enter second number: 5
The sum of 4 and 5 is 9.0
The subtraction of 4 and 5 is -1.0
The multiplication of 4 and 5 is 20.0
The division of 4 and 5 is 0.8