Answered step by step
Verified Expert Solution
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
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 usedStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started