Question
4. Write a python program named calculator.py to simulate a simple calculator. Your program should ask your user for two numbers and the operation the
4. Write a python program named calculator.py to simulate a simple calculator. Your program should ask your user for two numbers and the operation the user wants to apply on the given numbers. Allow your users to input
a. + or a to indicate the addition,
b. - or s to indicate the subtraction,
c. * or m to indicate the multiplication,
d. / or d to indicate the division,
e. % or r to indicate the remainder,
f. ^ or p to indicate the power of operation.
Your program's output should look something like this: Enter two numbers: 5, 2 Enter the operation: p Result: 5^2 = 25
Note: the user should enter the two numbers together in the same line (as shown above) Note: your operations should work whether the user enters the appropriate letter or symbol. Note: In the division operation, you should print an error message if the user enters a zero as the divisor operand (as shown in the sample output below)
Enter two numbers: 5, 0 Enter the operation: / Cannot compute! The divisor operand should not be zero!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started