Javatpoint Logo
Javatpoint Logo

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    

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

Example 1:

Output:

Enter first number: 10
Enter second number: 20
The subtraction of 10 and 20 is -10

Example 2:

Output:

Enter first number: 10
Enter second number: 20
The multiplication of 10 and 20 is 200

Example 3:

Output:

Enter first number: 10
Enter second number: 20
The division of 10 and 20 is 0.5






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA