This is my data file (called “studentdata.txt”)
joe 10 15 20 30 40
bill 23 16 19 22
sue 8 22 17 14 32 17 24 21 2 9 11 17
grace 12 28 21 45 26 10
john 14 32 25 16 89
I need to calculate the average grade for each student and print out the student’s name along with their average grade. I can extract the name with no problem and determine the number of exam scores, but I can not figure out how to sum the exam scores. This is what I have so far:
file=open("studentdata.txt","r")
for aline in file:
data=aline.split()
print((data[0]),"Average grade:")
print(len(data[1:]))
file.close()