I wanna this assignment work with python programming Part l The first part of th
ID: 3632687 • Letter: I
Question
I wanna this assignment work with python programmingPart l
The first part of this program should allow the user to enter a student’s last name and five test scores.
The program should accept student data until the word “DONE” is entered for the student name. This data should be printed to the screen in tabular format see below). The data also should be stored in a file. One student data should be stored per line.
Screen output format
Name Test Scores 1 2 3 4 5
Williams 98 87 67 99 87
Smith 88 78 89 76 88
File output format
Williams 98 87 67 99 87
Smith 88 78 89 76 88
Part ll
The second part of this program should read the data from the file. The program should calculate each
Student’s average and the class average. The program print the results to the screen (see below).
Part ll screen output format
Name Average
Williams 87.6
Smith 83.8
Class Average: 85.7
Be sure to include the required comments as discussed in previous assignments. Remember to turn in a copy the source code and printout of the data file your program created. Save a copy of the program to the :drive in my inbox
Explanation / Answer
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: ")
whilename !="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: ")
ifline =="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()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.