Gradebook

The Task

You'll be given a gradebook. In file form. Here it is at repl. You'll pull data from the file, compute averages, and then write those averages to an output file. See below for my output. Yours should be identical.

You'll need to know how to read from and write to a file. That's explained at the end of the Strings and Files Chapter.

Details

Take a look at the gradebook data. (See the section above if you don't yet have it.)

The first line identifies the columns. After come student names and grades.  So for instance Jacart Skald has two homework grades of 57 and 58 (slacker), then a project grade of 71, then a quiz grade of 93, etc.

Place the grade book into a text file (one text file) and read from that. (If you begin with the repl linked above, that's already been done for you.) Compute the semester average for each student. Use the formula: semester average = homework average * 0.2 + quiz average * 0.2 + project average * 0.6. Write student names followed by their category averages and semester average into a new file named averages.txt. Round averages to the nearest hundredth. Format your output as below.

Skald, Jacart: hw avg = 71.57, quiz avg = 96.0, proj avg = 79.5, sem avg = 81.21

Zommersun, Alephia: hw avg = 75.57, quiz avg = 63.5, proj avg = 95.0, sem avg = 84.81

Anneld, Thildert: hw avg = 82.86, quiz avg = 87.0, proj avg = 76.5, sem avg = 79.87

I suggest that  you store your data in a dictionary or dictionaries. Keys? Names I'd think, stored perhaps as a tuple of last name then first name. Values? Perhaps a  list of lists, where the first sublist contains homework, the second quizzes, the third projects.

You'll no doubt have many functions. But one will be the master function - the only function that's called, the function that orchestrates the execution of all the others. Call this master function compute_grades. It will have just one parameter - the name of the text file from which the program will read. The only line of code that won't be contained in some function or other is compute_grades(file_name).

Your Grade

When I grade your program, I'll place another gradebook in a new file. You'll need to grab that new gradebook and drop it into your project; and then you'll direct your project to read from that new file. It will be formatted in precisely the same fashion as the example gradebook I gave you.

You'll then take your output file to a repl that will check your output file.

You may assume that that new grade book will have grades of the three sorts in the grade book below. You may not assume that it will have the same number of each type or have them in the same order.

Extra Credit: Statistical Analysis

Produce a simple three-part statistical analysis of each of the averages you were asked to compute above. In particular, compute the mean, median and mode of the homework averages, the quiz averages, the project averages and the semester averages. Write these to a file named perhaps analysis.txt.  Before you compute median and mode, round the averages to the nearest one. So for instance 71.57 will be rounded to 72. Do not round before you compute mean.

My analysis is found below.

Averages and Analysis

My averages:

Skald, Jacart: hw avg = 71.57, quiz avg = 96.0, proj avg = 79.5, sem avg = 81.21

Zommersun, Alephia: hw avg = 75.57, quiz avg = 63.5, proj avg = 95.0, sem avg = 84.81

Anneld, Thildert: hw avg = 82.86, quiz avg = 87.0, proj avg = 76.5, sem avg = 79.87

Grummet, Molavia: hw avg = 69.71, quiz avg = 62.0, proj avg = 65.5, sem avg = 65.64

Slipe, Brunhildrun: hw avg = 83.71, quiz avg = 74.5, proj avg = 76.5, sem avg = 77.54

Momasuns, Nis: hw avg = 91.29, quiz avg = 61.5, proj avg = 71.5, sem avg = 73.46

Brazerlow, Thuckle: hw avg = 78.71, quiz avg = 68.5, proj avg = 70.5, sem avg = 71.74

Allodrune, Kikkerflew: hw avg = 66.86, quiz avg = 64.0, proj avg = 68.5, sem avg = 67.27

Gogallia, Davisum: hw avg = 75.43, quiz avg = 69.0, proj avg = 81.0, sem avg = 77.49

Plickerton, Hattle: hw avg = 72.0, quiz avg = 61.5, proj avg = 56.0, sem avg = 60.3

Couffe, Quidrun: hw avg = 72.14, quiz avg = 77.5, proj avg = 89.0, sem avg = 83.33

Serendip, Lackley: hw avg = 77.0, quiz avg = 81.0, proj avg = 65.0, sem avg = 70.6

Keyzrip, Kallimayhew: hw avg = 65.86, quiz avg = 88.5, proj avg = 95.5, sem avg = 88.17

Storilore, Cleister: hw avg = 73.29, quiz avg = 66.0, proj avg = 80.0, sem avg = 75.86

Eideer, Quorest: hw avg = 71.43, quiz avg = 69.5, proj avg = 86.0, sem avg = 79.79

Damalock, Lor: hw avg = 68.57, quiz avg = 56.5, proj avg = 52.5, sem avg = 56.51

Moorse, Brannert: hw avg = 80.57, quiz avg = 72.5, proj avg = 93.5, sem avg = 86.71

Loslalia, Quide: hw avg = 69.43, quiz avg = 59.5, proj avg = 64.5, sem avg = 64.49

Yeerst, Azard: hw avg = 66.29, quiz avg = 81.5, proj avg = 76.0, sem avg = 75.16

Dowallia, Landerlist: hw avg = 74.29, quiz avg = 71.0, proj avg = 82.0, sem avg = 78.26

Zuzollersky, Gradlent: hw avg = 84.43, quiz avg = 89.0, proj avg = 76.0, sem avg = 80.29

Tukoku, Prezzard: hw avg = 74.0, quiz avg = 71.5, proj avg = 73.5, sem avg = 73.2

Prizlest, Elard: hw avg = 62.0, quiz avg = 73.0, proj avg = 80.5, sem avg = 75.3

Zetamann, Mourly: hw avg = 75.0, quiz avg = 58.0, proj avg = 85.5, sem avg = 77.9

My analysis:

homework: mean = 74.25, median = 73.5, mode(s) = 72

quiz: mean = 71.77, median = 70.5, mode(s) = 62

project: mean = 76.67, median = 76.0, mode(s) = 76

semester: mean = 75.2, median = 76.5, mode(s) = 78 80