To make simple calculator in python to perform basic mathematical operations such as add, subtract, multiply, and divide two numbers entered by the user. To make calculator in python, first provide 5 options to the user, the fifth option for exit. After providing all the five options to the user, ask from user to enter his/her choice and perform the desired operation as shown in the program given below.
Following python program provides options to the user and ask to enter his/her choice to perform and show the desired result as output:
# Python Program - Make Simple Calculator while True: print("1. Addition") print("2. Subtraction") print("3. Multiplication") print("4. Division") print("5. Exit") choice = int(input("Enter your choice: ")) if (choice>=1 and choice<=4): print("Enter two numbers: ") num1 = int(input()) num2 = int(input()) if choice == 1: res = num1 + num2 print("Result = ", res) elif choice == 2: res = num1 - num2 print("Result = ", res) elif choice == 3: res = num1 * num2 print("Result = ", res) else: res = num1 / num2 print("Result = ", res) elif choice == 5: break else: print("Wrong input..!!")
Here are some sample runs of the above python program to illustrates how to make a simple calculator. This is the first snapshot:
Below is the second snapshot:
Here is the third snapshot:
You may also like to learn or practice the same program in other popular programming languages: