Question: import math def addition(num1, num2): return num1 + num2 def subtraction(num1, num2): return num1 - num2 def multiplication(num1, num2): return num1 * num2 def division(num1,

import math

def addition(num1, num2): return num1 + num2

def subtraction(num1, num2): return num1 - num2

def multiplication(num1, num2): return num1 * num2

def division(num1, num2): return num1 / num2

def remainder(num1, num2): return num1 % num2

def exponentiation(num1, num2): res = 1 num = int(num2) if (num2!=0): for i in range(num): res = num1*num1 else: res = 1 return (res)

def Squareroot(num): return (math.sqrt(num))

print("Choose one of the operations") print("+ for Addition") print("- for Subtraction") print("* for Multiplication") print("/ for Division") print("% for Remainder") print("^ for Exponential") print("s for Square Root")

num1 = float(input("Enter first number , then enter the operator then enter the second number: "))

while True: oprt = input("") num2 = float(input("")) if oprt in ('+','-','*','/','%','^','s'): if (oprt == '+'): res = addition(num1, num2) print("", num1, "+", num2, "=", res) num1 = res elif (oprt == '-'): res = subtraction(num1, num2) print("", num1, "-", num2, "=", res) num1 = res elif (oprt == '*'): res = multiplication(num1, num2) print("", num1, "*", num2, "=", res) num1 = res elif (oprt == '/'): res = division(num1, num2) print("", num1, "/", num2, "=", res) num1 = res elif (oprt == '%'): res = remainder(num1, num2) print("", num1, "%", num2, "=", res) num1 = res elif (oprt == '^'): res = exponentiation(num1, num2) print("", num1, "^", num2, "=", res) num1 = res elif (oprt == 's'): res = Squareroot(num1,num2) print("",num1,"s", num2, "=", res) num1 = res str = input("If you want to add more numbers press enter then choose the operator you want after that type the second number or press q or Q to exit: ") if(str == 'Q' or str == 'q'): break else: print("Error")

In python. Please add this to the calculator and provide screenshot of the output with examples for M P and Rn. Users now should be able to use the = operator or enter to do calculations.

Program should be able to handle incorrect inputs (like other characters or symbols). If a user enters incorrect input, the program resumes from the last correct input. No exceptions should occur.

Users should be able to use the M character to save the last input or result. Users can save as many numbers as they want. Users can list the saved numbers by using the P character. User can retrieve and continue with any number they want from the list by using Rn where n is any number from the list larger than 0 (e.g. R1 will retrieve the first save element, R2 second, ) Entering invalid number should print: Result does not exist at location. List exists as long as the program runs. Everytime program is restarted the list is empty. Store list in memory.

Please provide screenshot of the output with examples. For example 10 + 20 = 30 and then when user press M it saves the result or when you press P it lists the saved numbers or Rn to retrieve R1 will retrieve the first save element R2 second...

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!