Untitled

mail@pastecode.io avatar
unknown
plain_text
7 days ago
903 B
1
Indexable
Never
def add(x,y):
    return x + y
def sub(x,y):
    return x - y
def multiply(x,y):
    return x * y
def division(x,y):
    return x / y

print("1. ADD \n2. SUB \n3. MULTIPLY \n4. DIVISION \n ")

while True:
    choice = input("Enter choice:")
    if(choice in ("1","2","3","4")):
        try:
            num1 = float(input("Enter num1:"))
            num2 = float(input("\nEnter num2:"))
            if(choice=='1'):
               print("\nadd result=",add(num1,num2))
            elif(choice=='2'):
               print("\nsub result=",sub(num1,num2))
            elif(choice=='3'):
               print("\nmultiply result=",multiply(num1,num2))
            elif(choice=='4'):
               print("\ndivision result=",division(num1,num2))


        except ZeroDivisionError:
            print("Sorry ! You are dividing by zero ")

    else:
        break
            
Leave a Comment