Question: Fun with Files For this programming challenge you will be importing a simple text file, named FunWithFiles.txt, into Python, editing said file, and saving the

Fun with Files

For this programming challenge you will be importing a simple text file, named FunWithFiles.txt, into Python, editing said file, and saving the changes to the file. The text file will contain three lines of text (described below). Your program will read each line, store the word contained on each line into a variable in your Python program, print the contents to the output screen (in VS Code), which is called STDOUT, then ask the user for their favorite movie. Finally, your program will append the user's choice to the 4th line (underneath Breakfast Club) of the text document and save the file. Make sure the text file is located on your DESKTOP, so that I do not have to change the entire path when I am testing your programs on my computer. The path should be C:\Users\YOUR_USER_NAME\Desktop\FunWithFiles.txt

Program Instructions:

Create a single text file named FunWithFiles.txt (on your Desktop) with the following words in it, each on its own line:

Last of the Mohicans

Wind River

The Breakfast Club

Import the text file and have Python store each item into a variable

Print the contents of the file to the standard output area (which is where we have been seeing all of our data printed in this class so far), located in the OUTPUT/TERMINAL section in VS Code.

Ask the user for their favorite movie

Append the user's favorite movie choice to the file and save the file

You should be able to open your text file, AFTER the user has entered their favorite movie choice and the file has been saved, and see the new movie title right below The Breakfast Club.

Using Functions:

You should note that from here on out we WILL BE using functions in all of our programs. Therefore, your program should have the following functions for this assignments:

main():

calls FileControl()

FileControl():

Processes FunWithFiles.txt

Prints the contents to the screen

Asks the user for their favorite movie

Appends the user's movie choice to FunWithFiles.txt and saves the file

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!