Untitled
unknown
plain_text
a year ago
983 B
8
Indexable
def add(x,y):
return x+y
def sub(x,y):
return x-y
def mul(x,y):
return x*y
def div(x,y):
return x/y
print("1. ADDITION \n2. SUBTRACTION \n2. MULTIPLY \n2. DIVISION")
while True:
choice = int(input("Enter choice:"))
if(choice in (1,2,3,4)):
try:
num1 = float(input("Enter num1:"))
num2 = float(input("Enter num2:"))
except ValueError:
print("Error ocured")
continue
if(choice == 1):
print("Sum :", add(num1,num2))
elif(choice == 2):
print("subtraction :", sub(num1,num2))
elif(choice == 3):
print("Muliply :", mul(num1,num2))
elif(choice == 4):
print("Division :", div(num1,num2))
next = input("Ener choice:(yes/no)")
if(next=="yes"):
continue
else:
break
else:
print("invalid input")
Editor is loading...
Leave a Comment