Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 3 (35) Design a calculator that performs four operations: addition, mult

ID: 3594795 • Letter: P

Question

Problem 3 (35) Design a calculator that performs four operations: addition, multiplication, division and subtraction with 2 integer type numbers a) Ask user what type of operation to perform (+, , * or/) a. If the user inputs 'none' then the program terminates. Otherwise it will keep continuing the calculation. (hint: use while) b) Ask user to provide 2 integer number inputs c) Perform operation (whatever operation they mentioned in a) d) Print result e) In division operation, perform a check if the denominator is a 0. If it is 0, then print a message that- denominator cannot be 0 while performing a division operation

Explanation / Answer

# Python implementation of the code :

op = input('''
Please type in the math operation you would like to complete:
+ for addition
- for subtraction
* for multiplication
/ for division
none for termination
''')


if op == "+":
a = int(input("enter numbr 1 "))
b = int(input("enter number 2 "))
print("{} + {} = {}".format(a,b,a+b))
elif op == "-":
a = int(input("enter numbr 1 "))
b = int(input("enter number 2 "))
print("{} + {} = {}".format(a,b,a-b))
elif op == "*":
a = int(input("enter numbr 1 "))
b = int(input("enter number 2 "))
print("{} + {} = {}".format(a,b,a*b))
elif op == "/":
a = int(input("enter numbr 1 "))
b = int(input("enter number 2 "))
if b == 0:
print("denominator cannot be zero")
continue
print("{} + {} = {}".format(a,b,a/b))
elif op =="none":
break
else:
print("Use only +, -, *, / operators")
pass

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote