Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is python Problem. please help to make this program Create a function that will take a file name as an argument and another filename

image text in transcribed

This is python Problem. please help to make this program

Create a function that will take a file name as an argument and another filename to write the program output to. This function should attempt (use try except) to open the file associated with that file name. Error will be caught if the file does not exist. The program will read each line of that file and try to compute the expression (assume that each line is one mathematic expression, you can use python function eval(...) for this purpose). Unsupported operators should be caught. It should then write the result of that operation to an output file (which is the second argument of this function). Upon unsupported operation, "bad expression" will be written to output file instead and the program still continues until it reaches end of file. The program should inform user about successful file creation if no error occurs. Below is an example of the program session: Example of progress session: Please enter your input file: math exp.txt Please enter your output file: result.txt Output file is successfully created. The output is written to result.txt Content of math exp.txt and result.txt Line number math_exp.txt result.txt 15 12 bad expression 1+2+3*4 3 4-10/xx

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions