Home » Python make simple Calculator

Python make simple Calculator

by Online Tutorials Library

Python Program to Make a Simple Calculator

In Python, we can create a simple calculator for performing the different arithmetical operations, such as addition, subtraction, multiplication, and division.

Approach:

  • We can choose the desired operation from the option of a, b, c, and d.
  • We can take two numbers, and if… elif… else, branching is used for executing the particular operation.
  • We will use add(), subtract(), multiply() and divide() function for evaluation the respective operation in the calculator.

Example:

Code: for Simple Calculator

Output:

Case – (1):

Please select the operation.  a. Add  b. Subtract  c. Multiply  d. Divide  Please enter choice (a/ b/ c/ d):  d  Please enter the first number:  1  Please enter the second number:  2  1 / 2 = 0.5  

Case – (2):

Please select the operation.  a. Add  b. Subtract  c. Multiply  d. Divide  Please enter choice (a/ b/ c/ d): b  Please enter the first number:  12  Please enter the second number:  11  12 - 11 = 1  

You may also like