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.
Please select operation -
a. Add
b. Subtract
c. Multiply
d. Divide
Select operations form a, b, c, d: "c"
Please enter first number: 11
Please enter second number: 4
11 * 4 = 44
Code: for Simple Calculator
Output:
Case - (1):
Case - (2):