Data Work

You'll be working with the datafile "sample-grades.csv", although you might want to test your code on a .CSV file that you create just for testing purposes.

1. Create the function getCSVData(filename) which will return a list of lists, given a string naming the file to read.  Suppose you had a file called "Fred.csv" which contained the following string "A,B,C\r\n12,13,14\r\n" (notice that it consists of 2 lines when printed.  Then getCSVData("Fred.csv") would return the following list of lists:
    [['A','B','C'],['12','13','14']]
So, each element of the main list corresponds to the data from a single line, and each such sublist has elements which were the cells of the original table.

2. Create the function calcMean(column_header,classno), which will be given a string that should correspond  to the contents of one of the cells in the first row (a column header), and the second argument is a number corresponding to which class you're interested in (1, 2, 3 or 4).  calcMean will return the average (mean) of all the grades in the requested column for the students in the requested class, or it will return -1 if the requested column_header is not found or the classno is not in the range 1 to 4 (in other words, if there's no such test or no such class).  Remember, if there's missing data in the column, you still have to compute the mean correctly. For example:

	calcMean('Quiz 1',1)  # returns 26.87...
	calcMean('Test 2',2)  # returns 44.73...
	calcMean('Yo',67)     # returns -1

Put the results of calcMean('Project',3) into the Comments-to-Teacher

3. Create the function studentGrade(studentNo) which will be given a valid student number, and will calculate that student's grade, adding up the contributions from  tests 1 and 2, quizzes 1 and 2, project and final-exam grades, but not including the extra credit.  Here's how the contribution from Quiz 2 would be calculated: suppose the student gets 15 on Quiz 2.  Since this quiz is out of 25 points, that's equivalent to 60 out of 100.  But the test weight for Quiz 2 is 0.08, so 0.08 * (15/25) * 100 = 4.8.  Add up all such contributions to get the course grade.  For this problem, if the student missed a test/quiz/project or final, give him a -1 course grade (we'll fix that problem at another time).  Example for student 1:

	0.08*(20/30)*100 + 0.17*(45/60)*100 + 0.08*(11.5/25)*100 + 0.17*(36/50)*100 + 0.25*(75/100)*100 + 0.25*(54/100)*100 = 66.25
	studentGrade(1)  # returns 66.25...

4. Allow a user to ask for the results in problems 2 and 3 interactively. So create a question/answer dialog (create the function AskMe()) that will repeatedly prompt the user in the following way (the underlined/bold text shows the responses of the user).  Design appropriate error messages for user responses that your program cannot satisfy (asking for incorrect column headers, etc.).

1. get a class mean grade for an assessment
2. get a student's course grade
3. exit
Please enter [1-3]: 1
Which class [1-4]: 2
Which assessment: Quiz 1
The Quiz 1 average for class 2 is 28.451612903225808

1. get a class mean grade for an assessment
2. get a student's course grade
3. exit
Please enter [1-3]: 2
Which student [1-122]: 1
Student 1 course grade is: 66.2533

1. get a class mean grade for an assessment
2. get a student's course grade
3. exit
Please enter [1-3]: quit
Please enter [1-3]: get me out of here
Please enter [1-3]: 3
Bye.