Python scripting

profileAdejoke
CIS1233.4PerformanceAssessment.docx

Performance Assessment 3.4 – Reading and Writing Files

Task 1 – Pseudocode

Now you are going to create pseudocode for three functions readfile, writefile, and appendfile along with the main program. These functions should work together to read, write and append a line onto a file.

Let’s start with the pseudocode

Function readfile

End.

Function writefile

End.

Function appendfile

End.

Program Main

End.

Deliverables for Task 1

· Pseudocode to read in and write out data to a file

Task 2 – Open, read and sort a file

Now let’s put together the program. Open the Python IDLE program and create a new program called <Your Name>_PA31 in this Window

Create a function named readfile which opens the file names.txt in the Python Files directory. Read in all names, sort them, and then print them out to the screen.

Take a screenshot of your program and another of your output.

Create a second function called writefile that will take the sorted output from readfile and write back to sorted_names.txt.

Add a third function called appendfile that will add a line to the bottom of the sorted output from the writefile function.

Take a screenshot of your completed program and another of your output.

Deliverables for Task 2

· Screenshot of your read in function and the output when it is run

· Screenshot of your write function and the output when it is run