Python program to perform the arithmetic operation
Python program to perform the arithmetic operation
This program will write a code to perform some basic arithmetic operations like addition, subtraction, multiplication, exponent, modulus, and division. Here we first need to enter two numeric values, and then by using these values, we will perform the Arithmetic Operations.
Source Code
The following is a basic source code that allows us to perform arithmetic operations in Python:
#Program to perform basic arithmetic operations
#Take inputs from user number1 = input("Enter first number: ")
number2 = input("Enter first number: ")
# Addition of two numbers
sum = float(number1) + float(number2)
# Subtraction of two numbers
sub = float(number1) - float(number2)
# Multiplication of two numbers
mul = float(number1) * float(number2)
#Division of two numbers div = float(number1) / float(number2)
# Modulus of two numbers mod = float(number1) % float(number2)
# Exponent of two numbers expo = float(number1) ** float(number2)
# Print the sum
print("The sum of",number1,"and",number2,"is",sum)
# Print the subtraction
print("The subtraction of",number1,"and",number2,"is",sub)
# Print the multiplication
print("The multiplication of",number1,"and",number2,"is",mul)
# Print the division
print("The division of",number1,"and",number2,"is",div)
# Print the modulus
print("The modulus of",number1,"and",number2,"is",mod)
# Print the exponent
print("The exponent of",number1,"and",number2,"is",expo)
Output
Here is the output:

Explanation: In this program, we will take two numbers as input and store them in two different variables, number1 and number2, respectively. Then, we will calculate different arithmetic operations and store them in a separate variable. Finally, it prints all the arithmetic operations in a sequence using the print function.
