Help with 9/9 - How is everybody doing?


#1


Running the code above returns the error you see there. What am I doing wrong and how do I fix it?


#2

'students' is not defined

would suggest the array has not been defined. Be sure the array exists above line 53:

students = [ lloyd, alice, tyler ]

This is a list of references that is being passed to the function in the call expression on line 53.


#3

Thank you very much!


#4

At this stage we don't have to keep the elementary code we got through the exercises with. It can be improved. In this final exercise, we are actually free to explore. For instance, rather than an if..elif logic structure for the letter grade, we can use a sieve like structure in a loop with the help of a look up table.

G = {'A':(90,100),'B':(80,90),'C':(70,80),'D':(60,70),'F':(0,60)}

Our function can now take a score and match it to the tuple it fits in.

def get_letter_grade(grade):
    for letter in G:
        a, b = G[letter]
        if ( a <= grade and grade <= b ):
            return letter