Calculator program using Python
Create a simple calculator which can perform basic arithmetic operations like addition, subtraction, multiplication, or division depending upon the user input. Approach :
- User chooses the desired operation. Options 1, 2, 3, and 4 are valid.
- Two numbers are taken and an if…elif…else branching is used to execute a particular section.
- Using functions add(), subtract(), multiply() and divide() evaluate respective operations.
Please select operation - 1. Add 2. Subtract 3. Multiply 4. Divide Select operations form 1, 2, 3, 4 : 1 Enter first number : 20 Enter second number : 13 20 + 13 = 33
- Python
Output:
Please select operation - 1. Add 2. Subtract 3. Multiply 4. Divide Select operations form 1, 2, 3, 4 : 1 Enter first number : 15 Enter second number : 14 15 + 14 = 29
Comments