Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Intelligent Information And Database Systems Third International Conference Achids 2011 Daegu Korea April 2011 Proceedings Part 2 Lnai 6592

Authors: Ngoc Thanh Nguyen ,Chong-Gun Kim ,Adam Janiak

2011th Edition

3642200419, 978-3642200410

More Books

Students also viewed these Databases questions

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago

Question

What is group replacement? Explain with an example. (2-3 lines)

Answered: 1 week ago

Question

What lessons in OD contracting does this case represent?

Answered: 1 week ago

Question

Does the code suggest how long data is kept and who has access?

Answered: 1 week ago