Suppose that you are teaching multiple classes of 30 students each and you have to prepare an exam having 12 tasks on which they need to be graded. Each task has a different number of points, but you know their total number and the ranges in which each grade falls. After the exam, you would have a 30x12 matrix of values resembling the points each student received at each task. But to make things more obvious, you may need to attach the names of the students to them to see more easily whose points you are editing. Below you can see such a sample matrix.

```from bisect import bisect def grade(score): global task_note_breakpoints, grades i = bisect(task_note_breakpoints, score) return grades[i] task_note_breakpoints = [60, 69, 79, 89, 100] grades = 'A B C D F'.split(' ')[::-1] students_points = [ ('Renetta Buhler', [4, 1, 3, 6, 7, 10, 5, 4, 3, 5, 6, 3]), ('Celestina Uhler', [5, 2, 6, 7, 11, 12, 4, 3, 6, 7, 5, 7]), ('Iris Aldrete', [5, 1, 5, 8, 6, 4, 5, 3, 4, 8, 4, 6]), ('Yolanda Artiaga', [5, 3, 7, 6, 8, 12, 5, 4, 5, 6, 10, 5]), ('Lindy Tomaszewski', [5, 2, 7, 6, 11, 9, 6, 4, 6, 8, 8, 5]), ('Santana Moraga', [5, 2, 6, 6, 9, 12, 5, 4, 4, 7, 10, 7]), ('Ceola Withers', [5, 2, 6, 8, 11, 8, 4, 4, 6, 6, 10, 7]), ('Lorine Dallman', [4, 3, 7, 8, 9, 12, 6, 4, 4, 7, 10, 5]), ('Stuart Courville', [4, 3, 7, 6, 11, 10, 6, 4, 4, 8, 9, 7]), ('Sidney Ming', [2, 3, 7, 5, 9, 12, 3, 4, 4, 8, 9, 6]), ('Jeannetta Lenhardt', [5, 3, 5, 7, 10, 9, 4, 1, 3, 5, 9, 7]), ('Yuki Antone', [4, 2, 5, 9, 8, 7, 6, 3, 5, 5, 8, 7]), ('Jaimee Keeth', [4, 2, 7, 8, 4, 9, 6, 4, 3, 6, 8, 7]), ('Eliza Bolger', [3, 2, 5, 7, 11, 8, 6, 4, 3, 8, 8, 7]), ('Magdalen Box', [4, 2, 4, 8, 5, 9, 6, 4, 6, 7, 7, 7]), ('Leighann Bosque', [4, 2, 7, 9, 11, 5, 5, 4, 6, 7, 6, 7]), ('Hassie Klosterman', [3, 2, 6, 9, 8, 12, 5, 4, 2, 8, 10, 5]), ('Lorene Pedraza', [5, 3, 7, 9, 8, 10, 6, 1, 6, 6, 7, 7]), ('Erica Pearcy', [5, 3, 6, 3, 11, 12, 5, 2, 5, 6, 9, 5]), ('Shaunta Dawe', [5, 2, 4, 9, 7, 9, 5, 3, 3, 8, 9, 7]), ('Trent Bulfer', [4, 2, 4, 9, 9, 10, 3, 2, 6, 4, 9, 6]), ('Eddy Mattis', [4, 3, 4, 8, 11, 10, 5, 4, 5, 7, 5, 5]), ('Roberto Whichard', [5, 2, 5, 7, 11, 8, 4, 4, 6, 8, 5, 6]), ('Charlene Stayton', [5, 3, 6, 6, 9, 9, 2, 3, 6, 6, 6, 5]), ('Oneida Madewell', [4, 3, 5, 6, 10, 7, 6, 4, 6, 8, 8, 7]), ('Olga Tuel', [3, 3, 7, 7, 7, 12, 6, 4, 6, 6, 7, 7]), ('Yuko Jerrell', [5, 3, 6, 7, 11, 8, 3, 2, 6, 6, 10, 6]), ('Stanton Stigall', [5, 3, 7, 5, 10, 12, 6, 4, 3, 8, 8, 4]), ('Leann Honn', [5, 3, 5, 7, 6, 12, 5, 4, 6, 7, 8, 6]), ('Ezequiel Kondo', [5, 2, 6, 6, 10, 11, 4, 4, 6, 8, 9, 6]) ] graded = [] for name, points in students_points: sump = sum(points) person_data = [name, str(sump), grade(sump)] graded.append(person_data) # Uncomment to print the grades in plain text # print(', '.join(person_data)) # Only if you need the result in a table column_names = ('Student name', 'Total points', 'Grade') cols = len(column_names) th_str, td_str = [s * cols for s in ('<th>%s</th>', '<td>%s</td>')] result_table = ['<table><tr>{0}</tr>'.format(th_str) % (column_names)] for name, points, grade in graded: result_table.append( '<tr>{0}</tr>'.format(td_str) % (name, points, grade) ) result_table.append('</table>') result_table = ''.join(result_table) print(result_table) ```

This code produces output, which when embedded on this page results in the following table that can be printed in any style we want.

Renetta Buhler57F
Celestina Uhler75C
Iris Aldrete59F
Yolanda Artiaga76C
Lindy Tomaszewski77C
Santana Moraga77C
Ceola Withers77C
Lorine Dallman79B
Stuart Courville79B
Sidney Ming72C
Jeannetta Lenhardt68D
Yuki Antone69C
Jaimee Keeth68D
Eliza Bolger72C
Magdalen Box69C
Leighann Bosque73C
Hassie Klosterman74C
Lorene Pedraza75C
Erica Pearcy72C
Shaunta Dawe71C
Trent Bulfer68D
Eddy Mattis71C
Roberto Whichard71C
Charlene Stayton66D