Question: Hello, Please can you help me with corrections. I have screenshots of the two-part question and my code with the line numbers. Can you see

Hello, Please can you help me with corrections.

I have screenshots of the two-part question and my code with the line numbers.

Can you see my improvement reccomendation below and tell me at which line to add this input and how to write the code in

so that it outputs as per below requirement.

NB **** I need you to use my code and rewrite it with the final code that includes what the "improvement recomendation" asks for ***

You Must use / work with My code that I already have ***

Hello, Please can you help me with corrections. I have screenshots ofthe two-part question and my code with the line numbers. Can yousee my improvement reccomendation below and tell me at which line toadd this input and how to write the code in so thatit outputs as per below requirement. NB **** I need you touse my code and rewrite it with the final code that includeswhat the "improvement recomendation" asks for *** You Must use / work

Aspects of the submission that could be improved Please take note that the user should add the name of the txt file as an input and print out all of the equations together with the results. Use defensive coding to ensure that the program does not crash if the file does not exist and that the user is prompted again to enter the name of the file. - Create a simple calculator application that asks a user to enter two numbers and the operation (e.g. +,,x, etc.) that they'd like to perform on the numbers. Display the answer to the equation. Every equation entered by the user should be written to a text file. Use defensive programming to write this program in a manner that is robust and handles unexpected events and user inputs. Now extend your program to give the user the option to either enter two numbers and an operator, like before or to read all of the equations from a new txt file (the user should add the name of the txt file as an input) and print out all of the equations together with the results. Use defensive coding to ensure that the program does not crash if the file does not exist and that the user is prompted again to enter the name of the file. \#if else statement to print the answer for the given operator. \# Function to divide two numbers. \# If a number is divided by zero it will give the 'Division by Zero' message. def divide(x,y) : \( \mid \begin{array}{l}\text { try: } \\ \text { except ZeroDivisionError: } \\ \mid \text { return "Division by zero " }\end{array} \) \# Create a file in append and read mode. file = open("output.txt", "a+") while True: \( \mid \begin{array}{l}\text { \# Read numbers and operator } \\ \text { num1 = float(input("Enter first number: ")) } \\ \text { num2 = float(input("Enter second number: ")) } \\ \text { operator = input("Enter operator: ") } \\ \text { file.write(str(num1)+" "+operator+" "+str(num2)+" ") }\end{array} \) \# If else statement to print the answer for the given operator. if operator in (+,,m,,,) : if operator == ' + ' : print(add(num1, num2), " ") elif operator == ' ': | print(subtract(num1, num2), " ") elif operator == ': | print(multiply(num1, num2), " ") elif operator ==/ ': print(divide(num1, num2), " ) \# Option to continue or not. choice=input("ContinueY/NoN:"")ifchoice=="N":else

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!