First you will need to read the data.  The website containing the data is noted in the following code.  This code will access the web page and read the data one line at a time.  It is your responsibility to choose a storage mechanism that will maintain the data.   Most likely you will store the data as a list of lists (with each sublist containing the data for a student), or alternatively, a list of dictionaries (with each dictionary containing the data for a student).    The data should be put into the data structure as it is read in from the website.  You may use this code without referencing it.

import urllib.request #this loads a library you will need - put this at top of file.


def readWordList():

response = urllib.request.urlopen("http://www.cs.queensu.ca/home/cords2/marks.txt")

html = response.readline()

data = html.decode('utf-8').split()

return data
You will need to modify the above code so that you read in all lines of the file one by one and store them into your data structure (probably a list of lists)

Once your data has been read in, do the following:

1. Calculate the final mark for each student based on the following weightings.  Assignments are each worth 5% and were marked out of (24, 23, 13, 18, 18) respectively (A1, A2, A3, A4, A5).    The midterm is worth 30% and was marked out of 35 marks.  The final exam was worth 45% and was marked out of 65 points.  If the final mark is between 48 and 50, the final should be increased to 50.     Store the final marks along with the marks that you read in from the website.

2. Calculate the letter grade for each of the students based on their final marks.  Marks will be rounded to the closest integer for conversion.  For example, a mark of 85.1 would become 85.  A mark of 85.50 will be rounded to 86.  Store the letter grade along with the marks that you read in from the website. The grading scheme to use is the Queen's Arts and Science scheme shown here.

Grade

Numerical Course Average (Range)

A+

90-100

A

85-89

A-

80-84

B+

77-79

B

73-76

B-

70-72

C+

67-69

C

63-66

C-

60-62

D+

57-59

D

53-56

D-

50-52

F

49 and below

3. Convert the grade to a gpa following the table shown at the bottom of this page. Store the GPA along with the initial set of marks read in from the website.

Tasks 1-3 should be done immediately after the file has been read in.  Once this is done, the user should be provided with a menu that allows them to do the following (repeatedly until they choose the quit option from your menu):

1. Allow the user to enter a student number and display all the marks for the student (including the final mark, the letter grade and the gpa).

2. Display the (student number, gpa, final exam mark) information for students who scored the highest mark on the exam.  Note that this may be several students!

3. Display the (student number, gpa, final exam mark) information for students who scored below 50% on the final exam.

4. Display the students (student number, midterm mark, final exam mark) of students who scored greater than 80% on both the midterm and the final exam.

5. Increase all the final exam grades by 5%.  If the final exam exceeds 100%, cap it at 100%.   Recalculate the final mark, the letter grade and the gpa after this increase.

6. Calculate averages -- allow the user to specify which average mark they wish to see - A1, A2, A3, A4, A5, midterm, final exam, final mark or gpa.    Use the same function to calculate the average, no matter what choice the user enters.  Report the average with 2 decimal places.

7. Quit

You may assume that the user only enters numbers, but you should check to ensure the number that they entered is a valid menu choice.

Note that you should use appropriate functions to perform the specified tasks.   Think about the re-usability of your functions.   You may, someday write a similar program.  Divide your program into functions that might one day be useful to you.   Organization of your code is as important as making it work.  The organization of your program should minimize repeated code.  Before you start coding, make a plan.  What functions are you going to need?  What are the parameters and what does each function return.  Write each function and test it thoroughly before moving on to the next function.  This will make your coding and debugging job much easier.  Do not try to write the entire program at once.  Build it up one function at a time.

A "main" function should be included to start your program execution.  There should be NO "dangling" lines of code (that is, lines that are outside of a function (except for the "import" statement and a call to main (ie. main()) to make the program run.

Any data that needs to be accessed by a function should be passed in as a parameter. You must not use global variables.


Letter Grade

Grade Point

A+

4.30

A

4.00

A-

3.70

B+

3.30

B

3.00

B-

2.70

C+

2.30

C

2.00

C-

1.70

D+

1.30

D

1.00

D-

0.70

F

0.00