Question: python3 (1) a) Using a simple text editor (for example, the IDLE editor, TextEdit, Notepad), create a plain text (.txt) file of whatever you like

python3 (1) a) Using a simple text editor (for example, the IDLE editor, TextEdit, Notepad), create a plain text (.txt) file of whatever you like (e.g., favorite books, movies, important dates). The file should have at least two lines of text; it may be as long as you like (though you should test using a short file to start). Save the file. Examples:

Project9.txt or

DaysOfWk.txt. Then write a Python function, check_file, with one parameter, fname, the name of a file. check_file should open file fname, and print the contents of the file line by line, just as it appears in the file. None value is returned. The print function end=' ' optional argument may be useful. For example, for a text file that lists the days of the week:

Monday Tuesday Wednesday Thursday Friday Saturday Sunday

>>> check_file('DaysOfWk.txt') Monday Tuesday Wednesday Thursday Friday Saturday Sunday

(b)Write a Python function, fbkup, with one parameter, fname, the name of a text ('DaysOfWk.txt') file i.e. fbkup(fname). fbkup will create a backup for file fname, with the name DaysOfWK-bkup.txt. Another example, the backup file for file best-movies.txt should have the name best-movies-bkup.txt. fbkup should return the name of the new backup file. (See hint below) After creating the backup file, check your results. Import function check_file from Project_WK9_OptionalA.py. Call function check_file to print the file you created. Then call fbkup to backup that file.

(c)Finally, call check_file to print the backup file. For example,

check_file('DaysOfWk.txt') mybackupf = fbkup('DaysOfWk.txt') #'daysofwk-bkup.txt' check_file(mybackupf)

The result of both calls to check_file should look the same.

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!