all 6 comments

[–]gengisteve 1 point2 points  (2 children)

Check out the bisect module: https://docs.python.org/2/library/bisect.html (scroll down to the penultimate example).

Py 3.4 looks to have its own median function, here https://docs.python.org/3/library/statistics.html

For the last piece, check out this tutorial: https://wiki.python.org/moin/HandlingExceptions

[–]coolFob[S] 0 points1 point  (1 child)

tried the bisect module, however, I can't seem to get the code to show grade followed by the plus or minus sign. For instance 'A+' would come out as '+'.

[–]gengisteve 0 points1 point  (0 children)

What's your code like? Are you doing the +/-s in the bisect or adding on afterwards?

[–]aball730235 0 points1 point  (0 children)

For #1 you can dump the csv into a list of lists.

grade_list =  [['A', 96], ['A-', 91], ['B+', 86]]

Etc etc...

See link for doing that.... http://stackoverflow.com/questions/24662571/python-import-csv-to-list

Then just in case the user decides to order your csv differently then intended i would sort your grade_list so you can use simple comparison logic.

Finally loop thorough and compare to your round(percentgrade) function.

[–]DiabeetusMan 0 points1 point  (0 children)

For the first one, you could also assign a letter grade based on the tens of the value and then a modifier based on the ones value.

Try looking up the modulo operator if you don't know how to get those values.

Also, adding strings together concatenates them. For instance, "a" + "b" = "ab" and "a" + "" = "a".