Arithmetic operator in python| Python arithmetic operator| Arithmetic operator| Operators in python| python for beginner
Hello reader's,
In this post you are going to see about Arithmetic operator in python .
Arithmetic operator is basically performs four types of function that is Addition, Subtraction, Multiplication and Division. In this post you will see how you can perform these operations using python. To perform these operation you don't have to install any modules.
Addition :-
In addition operation you are going to add two number using python, for adding two number you have to take input from user , to take input from user type the code given below-
A = int(input("Enter number A: ")) This line of code is going to take first input from user and
B = int(input("Enter another number B: ")) this line of code is going to take second input from user.
print("The addition of A and B is: ", A+B) This line code is going to add the numbers taken as a input from user and also going to print the output.
Subtraction :- In subtraction you have to take input from user and subtract it, as previously done in addition we have take input from user to take input from user type the code given below or just copy and paste in your IDE
A = int(input("Enter number A: ")) This line of code is going to take first input from user and
B = int(input("Enter another number B: ")) this line of code is going to take second input from user.
print("The subtraction of A and B is: ", A-B) This line code is going to subtract the numbers taken as a input from user and also going to print the output.
Multiplication :-
As we have done in addition and subtraction we have to take two input from user and multiply it and print the output.
To take input from user type the code given below or just copy and paste in your IDE
A = int(input("Enter number A: ")) This line of code is going to take first input from user and
B = int(input("Enter another number B: ")) this line of code is going to take second input from user.
print("The subtraction of A and B is: ", A*B) This line code is going to Multiply the numbers taken as a input from user and also going to print the output.
Division :-
Now for the last time we have to take two input from user and perform the division operation .
To take input from user type the code given below or just copy and paste in your IDE
A = int(input("Enter number A: ")) This line of code is going to take first input from user and
B = int(input("Enter another number B: ")) this line of code is going to take second input from user.
print("The subtraction of A and B is: ", A/B) This line code is going to Divide (A/B) the numbers taken as a input from user and also going to print the output.
Code :-
#Addition
A = int(input("Enter number A: "))
B = int(input("Enter another number B: "))
print("The addition of A and B is: ", A+B)
#Subtraction
A = int(input("Enter number A: "))
B = int(input("Enter another number B: "))
print("The subtraction of A and B is: ", A-B)
#Multiplication
A = int(input("Enter number A: "))
B = int(input("Enter another number B: "))
print("The Multiplication of A and B is: ", A*B)
#Division
A = int(input("Enter number A: "))
B = int(input("Enter another number B: "))
print("The Division of A and B is: ", A/B)
Comments
Post a Comment
Thank you for sharing this.
You’re helping us become better. Want to stay in the loop? Subscribe to our YouTube channel.