Problem
A school has a number of professors. Each professor teaches one class. At the end of the semester, they test the students in their class. They then send a list of scores achieved by the students in their class to the headmaster.
The headmaster then takes the list of test scores received from each professor and combines the name of the professor with the list of test scores for the professor into one line of a comma separated values (CSV) file. An example of this CSV file is shown below.
Example input file namedgrades.csv
Professor Plum,75,77,66,100,90,76,90,91,88,62,84,63,91,67,76,72,83,80,57 Professor Disney,79,68,77,74,96,89,72,98,70,70,53 Professor Snape,73,99,73,75,65,76,91,81,81,82,62,95,86,99,43,90,100 Professor Thor,99,100,98,93,98,80,81,86,76,71,62,45,47 Professor Fury,69,63,82,54,57,82,92,101,68,45,90,78,72,52,96,66,72
The headmaster has asked you to write a program that will read in the CSV file and process the scores for each professor to determine the number of tests given, the grade distribution and the average grade for each professor.
Example program output
---------------------------------------------------------------------------------- | Professor Name | Tests | A | B | C | D | F | Average | ================================================================================== | Professor Plum | 19 | 5 | 4 | 5 | 4 | 1 | 78.32 | | Professor Disney | 11 | 2 | 1 | 6 | 1 | 1 | 76.91 | | Professor Snape | 17 | 6 | 4 | 4 | 2 | 1 | 80.65 | | Professor Thor | 13 | 5 | 3 | 2 | 1 | 2 | 79.69 | | Professor Fury | 17 | 4 | 2 | 3 | 4 | 4 | 72.88 | ----------------------------------------------------------------------------------
Hints:
- Use the stringsplit()method to split each line of the file into a list. Then use slicing to get the sub-list of test scores for a professor.
- Use the stringformat()method with a template string to align results in the output table.
- Use the following grading scale for the test scores:
A - greater than or equal to 90
B - greater than or equal to 80 and less than 90
C - greater than or equal to 70 and less than 80
D - greater than or equal to 60 and less than 70
F - less than 60
Instructions
- Create an algorithm calledgradesalgorithm.txtto solve the problem.
- Convert the algorithm into pseudocode calledgradespseudocode.txt.
- Code the program asgrades.py.
- Upload your algorithm (gradesalgorithm.txt), pseudocode (gradespseudocode.txt) and your program (grades.py) to D2L.