How to Make a Simple Calculator in Python2 min read

In this example,I’ll show you How to make a simple 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:

This is a simple calculator program that allows the user to perform basic arithmetic operations.

Here’s a brief explanation of how the code works:

  1. The program prints a menu of options to the console: addition, subtraction, multiplication, division, and exit.
  2. The user is prompted to enter their choice of operation.
  3. If the choice is 1, 2, 3, or 4, the program prompts the user to enter two numbers.
  4. The program then performs the chosen operation on the two numbers and prints the result to the console.
  5. If the choice is 5, the program exits.
  6. If the choice is none of the above, the program prints an error message.


Leave a Comment