I tried to create a function using which I want to do mathematical operations like (Addition and Multiplication), I could able to prompt the values and when I insert the values result is not returning as expect. enter image description here
Code
def addition(num1,num2):
return num1+num2 def
multiplication(num1,num2):
return num1*num2
print("1.addition")
print("2.multiplication")
choice = int(input("Enter Choice 1/2"))
num1 = float(input("Enter First Number:"))
num2 = float(input("Enter Second Number:"))
sum = float(num1)+float(num2)
multiply = float(num1)*float(num2)
if choice == 1:
print("additon of {0} and {1} is".format(num1,num2, sum))
elif choice == 2:
print("additon of {0} and {1} is".format(num1,num2, multiply))
See Question&Answers more detail:os