Practical 2.1

In this task you will apply what you learned from the if-elif-else statement to write a program to implement a basic arithmetic calculator for 2 numbers. Your program will need to prompt the user for:

The two numbers to be calculated.
The type of calculations to be performed, i.e. +, -, *, or /. The user must enter ‘+’, ‘-‘, ‘*’, or ‘/’ in the prompt instead of a numbered option. For example:
Operation (+,-,*,/): +
For the type of calculations (2), you must use a if-elif-else statement with the actual symbol for the type of calculation for the 4 possible operators indicated above.
Sample run:
Enter the first number: 2
Enter the second number:4
Enter the operation: *

Output:
The result of multiplying 2 and 4 is 8.

You will need to submit the following to complete this part of the practical:

Code documentation on Learn for Practical 2. In your documentation make sure you include test case for each type of calculations.

Scroll to Top