Write clearly with documentations where necessary as you write the program to so
ID: 3642829 • Letter: W
Question
Write clearly with documentations where necessary as you write the program to solve the following problem.
This is the end of the semester, and you are asked to write a program that will input the name of five students and their corresponding test scores (4 test scores for each student).
Then find the sum of the 4 test scores, calculate the average test score, and assign the grades as follows:
90-100-----------A
80-89------------B
70-79------------C
60-69------------D
Below 60---------F
Generate output in the table format below:
Student name
Test1
Test2
Test3
Test4
Total
Average
Grade
Explanation / Answer
names=[]
tests=[]
averages=[]
grades=[]
numstudents=5
for i in range(numstudents):
name=raw_input("Please input student's name. ")
names.append(name)
scores=[]
average=0
for j in range(4):
score=float(raw_input("Enter score from test number "+str(j+1)+" "))
scores.append(str(score))
average=average+score
tests.append(scores)
average=average/4
averages.append(str(average))
if average>=90:
grades.append("A")
elif average>=80:
grades.append("B")
elif average>=70:
grades.append("C")
elif average>=60:
grades.append("D")
else:
grades.append("F")
line="Student name "
for i in range(numstudents):
line=line+names[i]+" "
print line+" "
line= "Test1 "
for i in range(numstudents):
line=line+ tests[i][0]+" "
print line+" "
line= "Test2 "
for i in range(numstudents):
line=line+ tests[i][1]+" "
print line+" "
line= "Test3 "
for i in range(numstudents):
line=line+ tests[i][2]+" "
print line+" "
line= "Test4 "
for i in range(numstudents):
line=line+ tests[i][3]+" "
print line+" "
line= "Total "
for i in range(numstudents):
line=line+ str(float(averages[i])*4)+" "
print line+" "
line="Average "
for i in range(numstudents):
line=line+ averages[i]+" "
print line+" "
line= "Grades "
for i in range(numstudents):
line=line+ grades[i]+" "
print line+ " "
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.