One student has no grades — should average crash, return None, return 0.0, or stop the program dead?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Here is the four-student roster from the video. Each entry is a name list followed by a grades list, and the last student has no grades at all.
test_grades = [[['peter', 'parker'], [80.0, 70.0, 85.0]], [['bruce', 'wayne'], [100.0, 80.0, 74.0]], [['captain', 'america'], [10.0, 10.0, 80.0]], [['deadpool', 'duh'], []]]
Index into test_grades and assign Captain America's grades list — the whole list of numbers — to cap_grades.
The nested class list and get_stats
Record the shape [[first_name, last_name], [grade, grade, ...]] for one student, and write get_stats appending [stu[0], stu[1], average(stu[1])] for each student of class_list.
Four versions of average
Write all four bodies with the result each gives a student holding no grades: a ZeroDivisionError, a printed warning returning None, that warning plus return 0.0, and assert len(grades) != 0.
Exceptions versus assertions as a design choice
Write the closing distinction: a caught exception leaves the program running on values you choose, while an AssertionError is the tool for stopping a bad value dead.