Sending a Letter... Stucked!


#1

I don't know how the get_letter_grade got missing from my code. This is the error I keep getting: Oops, try again. get_letter_grade seems to be missing.

def average(number):
    total = sum(number)
    total = float(total)
    return total/len(number)
    
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    
    homework = 0.1*average(student["homework"]) 
    quizzes = 0.3*average(student["quizzes"])
    tests = 0.6*average(student["tests"])
    
    grade = 0.1*average(student["homework"]) + 0.3*average(student["quizzes"]) + 0.6*average(student["tests"])
    
    return grade
    
    def get_letter_grade(score):
        
        if score >= 90:
            return "A"
        elif score >= 80:
            return "B"
        elif score >=70:
            return "C"
        elif score >=60:
            return "D"
        else:
            return "F"
    
    
    print get_letter_grade
    print get_letter_grade(get_average(lloyd))

#2

hint: indention

your get_letter_grade function should be outside/after your get_average function


#3

I put it outside and I still got an error :

Traceback (most recent call last):
File "python", line 54, in
NameError: name 'get_letter_grade' is not defined

The new code:

def average(number):
    total = sum(number)
    total = float(total)
    return total/len(number)
    
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    
    homework = 0.1*average(student["homework"]) 
    quizzes = 0.3*average(student["quizzes"])
    tests = 0.6*average(student["tests"])
    
    grade = 0.1*average(student["homework"]) + 0.3*average(student["quizzes"]) + 0.6*average(student["tests"])
    
    return grade
    
    def get_letter_grade(score):
        
        if score >= 90:
            return "A"
        elif score >= 80:
            return "B"
        elif score >=70:
            return "C"
        elif score >=60:
            return "D"
        else:
            return "F"
    
    
    print get_letter_grade
print get_letter_grade(get_average(lloyd))

#4

you place the function call correctly, now the function itself

Please think about the indent/design of your program


#6