# -*- coding: utf-8 -*- """ Created on Thu Apr 8 14:41:03 2021 @author: user 1.Write a program that lets the user perform arithmetic operations on two numbers. Your program must be menu driven, allowing the user to select the operation (+, -, *, or /) and input the numbers. 2.Functions: (1)Function showChoice: This function shows the options to the user and explains how to enter data. (2)Function add: This function accepts two number as arguments and returns sum. (3)Function subtract: This function accepts two number as arguments and returns their difference. (4)Function multiply: This function accepts two number as arguments and returns product. (5)Function divide: This function accepts two number as arguments and returns quotient. """ def show_choices(): print('\nMenu') print('1. Add') print('2. Subtract') print('3. Multiply') print('4. Divide') print('5. Exit') def add(a, b): return a + b def subtract(a, b): return a - b def multiply(a, b): return a * b def divide(a, b): return a / b def main(): while(True): show_choices() choice = input('Enter choice(1-5): ') if choice == '1': x = int(input('Enter first number: ')) y = int(input('Enter second number: ')) print('Sum =', add(x, y)) elif choice == '2': x = int(input('Enter first number: ')) y = int(input('Enter second number: ')) print('Difference =', subtract(x, y)) elif choice == '3': x = int(input('Enter first number: ')) y = int(input('Enter second number: ')) print('Product =', multiply(x, y)) elif choice == '4': x = int(input('Enter first number: ')) y = int(input('Enter second number: ')) if y == 0: print('Error!! divide by zero') else: print('Quotient =', divide(x, y)) elif choice == '5': break else: print('Invalid input') main()