In this python basic program, we will perform mathematical operations on two numbers defined by the user.
Steps to solve the program
- Take two numbers and a mathematical operation of your choice (+,-,*,/) as input.
- Using if-else statements perform the corresponding operations on numbers.
- Print the output.
num1 = float(input("Enter number 1: "))
num2 = float(input("Enter number 2: "))
operation = input("Enter operation of your choice: ")
if operation == "+":
print(num1+num2)
elif operation == "-":
print(num1-num2)
elif operation == "/":
print(num1/num2)
elif operation == "*":
print(num1*num2)
else:
print("Invalid operation")
Output :
Enter number 1: 25
Enter number 2: 5
Enter operation of your choice: /
5.0
calculate the volume of a sphere.