Make calculator using python

 Q.  Write  a program to design a menu driven calculator 




n1 = int(input("Enter number 1: "))
n2 = int(input("Enter number 2: "))
print("Menu for Arithmetic Operation: \n 1. Addition \n 2. Subtraction \n 3. Multiplication \n 4. Division \n 5. Modulus \n 6. Float division \n 7. Exit")

choice = int(input("Enter your choice: "))
if(choice == 1):
    print(f' sum of {n1} and {n2} = {n1 + n2}')
elif(choice == 2):
    print(f' Subtraction of {n1} and {n2} = {n1 - n2}')
elif(choice == 3):
    print(f' Multiplication of {n1} and {n2} = {n1 * n2}')
elif(choice == 4):
    print(f' Qoutient of {n1} and {n2} = {n1 / n2}')
elif(choice == 5):
    print(f' Remainder of {n1} and {n2} = {n1 % n2}')
elif(choice == 6):
    print(f' Float division of {n1} and {n2} = {n1 // n2}')
elif(choice == 7):
    print(f'You have successfully exited the menu. \n Thank you.')
else:
    print(f'Not available.\n Choose the correct menu option.')
    


Hope you enjoy running this code. Here we have use if else statemts to design the menu driven calculator. Thank you.😊

Comments

Post a Comment