Use of arithmetic operators in python

Arithmetic operators are used to perform arithmetic operations like addition, subtraction, multiplication, division and exponent. The following program shows arithmetic operations by taking user inputs and then printing the output value.

# Use of addition operator

number1 = int(input("Enter your first number to add:"))
number2 = int(input("Enter your second number to add:"))

sum = number1 + number2

print("The sum of the entered two integer numbers are:", sum)


# Use of subtraction operator

number1 = int(input("Enter your first number to subtract:"))
number2 = int(input("Enter your second number to subtract:"))

subtraction = number1 - number2

print("The subtraction of the entered two integer numbers are:", subtraction)


# Use of multiplication operator

number1 = int(input("Enter your first number to multiply:"))
number2 = int(input("Enter your second number to multiply:"))

multiplication = number1 * number2

print("The multiplication of the entered two integer numbers are:", multiplication)


# Use of division operator

number1 = int(input("Enter your first number to be  divided:"))
number2 = int(input("Enter your second number to be divided by:"))

division = number1 / number2

print("The division of the entered number is:", division)


# Use of quotient operator

number1 = int(input("Enter your first number to find quotient of:"))
number2 = int(input("Enter your second number to be divided by:"))

quotient = number1 // number2

print("The quotient of the divided number is:", quotient)


# Use of remainder operator

number1 = int(input("Enter your first number to find remainder of:"))
number2 = int(input("Enter your second number to divide by:"))

remainder = number1 % number2

print("The remainder of the divided integer number is:", remainder)


# Use of exponent operator

number1 = int(input("Enter your first number to find the exponent of:"))
number2 = int(input("Enter your exponent number:"))

exponent = number1 ** number2

print("The exponent of the entered number is:", exponent)

Output:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments