104
Python program to do arithmetical operations
The arithmetic operations are performed by calculator where we can perform addition, subtraction, multiplication and division. This example shows the basic arithmetic operations i.e.
- Addition
- Subtraction
- Multiplication
- Division
Let’s understand the following example.
Example –
Output:
Enter first number: 10 Enter second number: 20 The sum of 10 and 20 is 30.0 The subtraction of 10 and 20 is -10.0 The multiplication of 10 and 20 is 200.0 The division of 10 and 20 is 0.5
Explanation –
In the above code, we have taken the user input as an integer using the input() function. Then, we have performed the arithmetical operation on the given numbers and print the result using the print statement. We used the format() method to format the string
Note – To learn more about the format() method, visit our format() method tutorial.
Next TopicPython Area of a Triangle