Python Program to Make Calculator

Make Calculator in Python

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.

Python Programming Code to Make Calculator

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("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:

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:

Tools
Calculator