Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help writing code for this assignment. I am using python 2. Here are the

ID: 3639257 • Letter: I

Question

I need help writing code for this assignment. I am using python 2.

Here are the directions

Write a python function to read list of student names and test scores that are formatted as shown:
Smith, Tom 99
Johnson, Curly 88
James, Linda 93
We know that there is one name and score per line, with comma between the last name and first as in:
last, first score
but there may be any amount of white space anywhere else in line.

The mission is to write python fuction that reads the input file and write three new output files, each with the white space crushed to a minimum, and data sorted as given:
The first file is sorted by test score, in order score first last(no commas), from high score to low score as in
99 Tom Smith
93 Linda James
88 Curly Johnson
The second file has to be sorted by last name, as last, first score (with single comma)
James , Linda 93
Johnson, Curly 88
Smith, Tom 99
The third file is sorted by first last score (no commas)
Curly Johnson 88
Linda James 93
Tom Smith 99

Explanation / Answer

# Take the inputs fileName = raw_input("Enter the file name: ") # Open the input file inputFile = open(fileName, 'r') outputFile = open("z:/python/payroll.txt", 'w') printNow ("%-15s%6s%15s" % ("Lat Name", "Test Scores", "Average")) # Read the data and print the report name = input("Enter the student's last name: ") while name != "Done": line = inputFile.readline() score1 = input("Enter the first score: ") score2 = input("Enter the second score: ") score3 = input("Enter the third score: ") score4 = input("Enter the fourth score: ") score5 = input("Enter the fifth score: ") if line == "Done": break dataList = line.split() name = dataList[0] testScores = int(dataList[1]) average = score1 + score2 + score3 + score4 + score5 / 5.0 outputFile.write(name + " " + str(testScores) + " " + str(average) + " ") printNow ("%-15s%6d%15.2f" % ("name", "average", "jclass average")) inputFile.close() outputFile.close()