#
# Copyright 2023, Ali Arya
# Anyone Can Code: Algorithmic Thinking
# Example 4.6p
#

#operation modules
def Add(num1, num2):
    return num1+num2
def Sub(num1, num2):
    return num1-num2
def Mul(num1, num2):
    return num1*num2
def Div(num1, num2):
    if num2 == 0:
        print("divide by zero!")
        return False
    else:
        return num1/num2
#main code
quit = False
while  not quit :
    operation = int(input("Enter operation type.  1 for add, 2 for subtract, 3 for multiply, 4 for divide, 0 to exit: "))
    if operation>0 and operation<5:
        num1 = int(input("Enter the first number: "))   #assume integer numbers
        num2 = int(input("Enter the second number: ")) 
    if operation == 0:
        quit = True
    elif operation == 1:
        print(Add(num1, num2))
    elif operation == 2:
        print(Sub(num1, num2))
    elif operation == 3:
        print(Mul(num1, num2))
    elif operation == 4:
        print(Div(num1, num2))
    else:
        print("Invalid operation!")

        
