Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago