So when Exercise 3 in the chapter I'm on looked like the following:

Write a function which is given an exam mark, and it returns a string — the grade for that mark — according to this scheme:

Mark Grade >= 90 A [80-90) B [70-80) C [60-70) D < 60 F

The square and round brackets denote closed and open intervals. A closed interval includes the number, and open interval excludes it. So 79.99999 gets grade C , but 80 gets grade B.

Let xs = [83, 75, 74.9, 70, 69.9, 65, 60, 59.9, 55, 50, 49.9, 45, 44.9, 40, 39.9, 2, 0]

Test your function by printing the mark and the grade for all the elements in this list.

Of course my response is going to look like:

def grader (x):

if x >= 90:

return "Outstanding"

elif x >=80 and x <90:

return "Exceeds Expectations"

elif x >=70 and x <80:

return "Acceptable"

elif x >=60 and x <70:

return "Pass"

elif x >= 50 and x < 60:

return "Dismal"

else:

return "Troll"

gradesum = 0

counter = 0

avggrade = 0

for grade in [83, 75, 74.9, 70, 69.9, 65, 60, 59.9, 55, 50, 49.9, 45, 44.9, 40, 39.9, 2, 0]:

print(grader(grade), "\t", grade)

gradesum = gradesum + grade

counter = counter + 1

avggrade = gradesum/counter

print("\r", "\t", grader(avggrade), "(overall average)", "\t", int(avggrade))

... yes, I went all Ravenclaw and made it output the average grade at the end. :)

*

Separately,

**zero2perl**now exists, thanks to

**zarhooie**, and if you like word ladders like me (and are down with the use of proper nouns and British spellings):

ZERO

HERO

HERB

KERB

KERN

PERN

PERL

See? Six simple steps. :)