#560 · File handling · Beginner · 35 XP · about 7 min
A teacher saves the class marks in a text file, one student per line: the student's name, a space, then their mark. Some names have several words, so the mark is always the last word on the line. The file may also contain blank lines, which you skip.
Write average_mark(filename) that returns the average of all the marks, rounded to one decimal place with round(total / count, 1). If the file holds no marks at all, return 0.0.
If marks.txt holds:
Asha 80 Ben 75 Anna Marie Lee 90
then average_mark('marks.txt') returns 81.7, because 245 / 3 = 81.666...
Every mark is a whole number from 0 to 100.
First solves only, ranked by stars and then time.