Calculator
A simple calculator that can add, subtract, multiply or divide depending upon the input from the user. In this example, we should have the knowledge of the following Python programming topics:
- Python Functions
- Python Function Arguments
- Python User-defined Functions
Explanation
In this program, we ask the user to choose an operation like add, subtract, multiply and divide. Options 1, 2, 3, and 4 are valid. If any other input is given, Invalid Input is displayed and the loop continues until a valid option is selected.
Two numbers are taken and an if...elif...else branching is used to execute a particular section. User-defined functions add(), subtract(), multiply() and divide() evaluate respective operations and display the output.