Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

fscanf retums a special value EOF that stands for...

Answered: 1 week ago