Python Program Addition Subtraction Division Multiplication
Python Program to perform Addition Subtraction Division Multiplication
In this article, we are going to understand the basic mathematical operations like Addition Subtraction Multiplication Division. So in other words we can say that we are going to discuss the following programs.
- Write a program to add two numbers.
- Write a program to subtract two numbers.
- Write a program to divide two numbers.
- Write a program to multiply two numbers.
In all the above programs we will take input from the user.
Let we start with our first program
“Addition of two numbers”
num1 = int(input("Enter First Number: ")) #Accepting first number from the user num2 = int(input("Enter Second Number: ")) #Accepting Second number from the user S = num1 + num2 #Adding the two numbers print("Sum of two numbers are: ", S) #Displaying the result NOTE: Same way we can add more than two numbers.
OUTPUT
“Subtraction of two numbers”
num1 = int(input("Enter First Number: ")) #Accepting first number from the user num2 = int(input("Enter Second Number: ")) #Accepting Second number from the user S = num1 - num2 #Subtracting the two numbers print("Difference of two numbers is: ", S) #Displaying the result
OUTPUT
“Division of two numbers”
num1 = int(input("Enter First Number: ")) #Accepting first number from the user num2 = int(input("Enter Second Number: ")) #Accepting Second number from the user S = num1 / num2 #Dividing the two numbers print("Result of Division of two numbers is: ", S) #Displaying the result
OUTPUT
NOTE: Division of two integers returns a floating point number as shown above.
NOTE: Division by ZERO returns Zero Division Error as shown below
“Multiplication of two numbers”
num1 = int(input("Enter First Number: ")) #Accepting first number from the user num2 = int(input("Enter Second Number: ")) #Accepting Second number from the user S = num1 * num2 #Multiply the two numbers print("Result of Multiplication of two numbers is: ", S) #Displaying the result NOTE: Same way we can multiply more than two numbers.
OUTPUT
Addition Subtraction Division Multiplication Program
MCQ of Computer Science Chapter Wise
2. Flow of Control (Loop and Conditional statement)
3. 140+ MCQ on Introduction to Python
4. 120 MCQ on String in Python
7. 100+ MCQ on Flow of Control in Python
8. 60+ MCQ on Dictionary in Python
Important Links
100 Practice Questions on Python Fundamentals
120+ MySQL Practice Questions
90+ Practice Questions on List
50+ Output based Practice Questions
100 Practice Questions on String
70 Practice Questions on Loops
70 Practice Questions on if-else
Disclaimer : I tried to give you the correct coding of ” Addition Subtraction Division Multiplication Program” , but if you feel that there is/are mistakes in the code or explanation of “Addition Subtraction Division Multiplication Program “ given above, you can directly contact me at csiplearninghub@gmail.com.