Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON ONLY Please follow all the directions and code using Python idle and make sure not to use the constructs prohibited in the list unless

PYTHON ONLY

image text in transcribed

image text in transcribedimage text in transcribed

Please follow all the directions and code using Python idle and make sure not to use the constructs prohibited in the list unless the question at the top asks you to use that construct. Also, do not use

if __name__ == "__main__":

main()

Instead, just invoke the main function normally.

1. create_file - takes filename as a parameter. The function creates an empty file. - An example is shown below: - create_file("myfile.txt") File myfile.txt should now be visible in the working directory 2. read_file - takes filename as a parameter and returns a string with file content. - An example is shown below, for the file myfile.txt assuming it has two separate lines, which are "This is The Pennsylvania " and "State University". 0 read_file("myfile.txt") Dutput: "This is The Pennsylvania State University" 3. read_file_lines This function takes filename as a parameter. and returns a list whose elements are representative of the lines in the file. An example is shown below, for the file myfile.txt assuming it has two separate lines, which are "This is The Pennsylvanio " and "State University". - read_file_lines("ryfile.txt") Dutput: ['This is The Pennsylvania , 'State University n '] 4. write_to_file separate lines, which are "This is The Pennsylvania " and "State University". write_to_file("ryfile.txt", ["University Park", "PA USA"]) File myfile, txt non loaks like the follawing:- myfile.txt x 2 University Park 3 5. append_to_file An example is show below, for the file myfile.txt assuming it has two separate lines, which are "This is The Pennsylvania " and "State University". - append_to_file("myfile.txt", ["University Park", "PA USA"]) File myfile.txt now looks like the following: myfile.txt 1 This is The Pennsylvania 2 State University 3 University Park 4 PA USA 5 Return values must be assigned to variables before used

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 Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions