Question: Please use python to solve it (e) This Python code copies a file, line by line. It presumes that the input and output files will

Please use python to solve it

Please use python to solve it (e) This Python code copies a

file, line by line. It presumes that the input and output files

(e) This Python code copies a file, line by line. It presumes that the input and output files will be in the same directory (folder) as the code itself. (This is a restriction we could relax by using libraries that let us navigate around file systems and use the operating system's standard file dialog boxes. But those are topics for another day.) infile-name = input("Please enter the name of the file to copy : ") infile open infile_name "r, encoding-'utf8') outfile_nameinput("Please enter the name of the new copy: " outfileopen outfile_name, 'w', encoding- 'utf8') for line in infile: outfile.write(line) infile.closeO outfile.closeO (The encoding= 'utf8" helps the automated checking process deal with cross-platform file storage differences.) (e.1) Copy this code into your lab7.py file on your own system (or, temporarily, into a separate file if that makes it easier for you to experiment, but this code needs to be in your Lab7.py file when you submit it). Package it into a function called replicate file that takes no parameters and returns no value (because it does all its work by prompting the user and reading and writing files). Test it out by copying a short text file Then download the Project Gutenberg version of The Adventures of Sherlock Holmes from http:// gutenberg org/cache/epub/1661/pg1661.txt?(Project Gutenberg is a wonderful resource for non-copyright-protected texts.) Call your file-copying function to make a copy of this file. Some problems have been reported with reading Project Gutenberg files. If you run into messages saying that Python can't decode a character, open the file with openCinfile name, r', errors-"ignore" (e.2) Modify your replicate_file function to take one parameter, a string. If the parameter is "line numbers", the copied file includes line numbers at the start of each line 1: Project Gutenberg's The Adventures of Sherlock Holmes, by Arthur Conan Doyle 3: This eBook is for the use of anyone anywhere at no cost and with 13052: subscribe to our email newsletter to hear about new eBookS If the parameter is anything else, the function just copies the file as before. Note that the line number is formatted and right-justified in a five-character field. You did this task last week, so you should be able to reuse most of last week's solution

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!