Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def read_grades_file(filename):
d = {}
f = open(filename, "r")
d['Name'] = f.readline().strip()
d['Projects'] = grades_to_float(f.readline())
d['Homeworks'] = grades_to_float(f.readline())
d['zyBooks'] = grades_to_float(f.readline())
d['Quizzes'] = grades_to_float(f.readline())
d['Midterm'] = float(f.readline())
d['Final'] = float(f.readline())
f.close()
return d
def grades_to_float(grades):
grades_list = []
for grade in grades.split():
grades_list.append(float(grade))
return grades_list
print(read_grades_file("C:\\Users\\herik\\git\\blah\\gmason.grades"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment