9/9 Student Becomes the Teacher


#1

Why is it asking if I remembered to print the letter grade?

I DID

These are the instructions:

Instructions

1.Finally, print out the result of calling get_class_average with your students list. Your students should be [lloyd, alice, tyler].

  1. Then, print the result of get_letter_grade for the class's average.

This is literally the last Python thing I need to finish. I'm at 99%, and I STILL don't know why this isn't right!

lloyd = {
    "name": "Lloyd",
    "homework": [90.0, 97.0, 75.0, 92.0],
    "quizzes": [88.0, 40.0, 94.0],
    "tests": [75.0, 90.0]
}
alice = {
    "name": "Alice",
    "homework": [100.0, 92.0, 98.0, 100.0],
    "quizzes": [82.0, 83.0, 91.0],
    "tests": [89.0, 97.0]
}
tyler = {
    "name": "Tyler",
    "homework": [0.0, 87.0, 75.0, 22.0],
    "quizzes": [0.0, 75.0, 78.0],
    "tests": [100.0, 100.0]
}

students = [lloyd, alice, tyler]

# Add your function below!
def average(numbers):
    total = float(sum(numbers))
    return total / len(numbers)
    
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    
    return homework*0.10 + quizzes*0.30 + tests*0.60
    
    
def get_letter_grade(score):
    if score >= 90:
        print "A"
    elif score >= 80 and score < 90:
        print "B"
    elif score >= 70 and score < 80:
        print "C"
    elif score >= 60 and score < 70:
        print "D"
    else:
        print "F"
        
def get_class_average(students):
    result = []
    for key in students:
        result.append(get_average(key))
    return average(result)
    

print get_class_average(students)
print get_letter_grade(get_class_average(students))

#2

Your code looks great! However, the function get_letter_grade is printing the letter instead of returning it. In functions it is best to return the value so that it can then be used by other functions or areas of the program.


#3

Yeah I literally figured it out, just after posting my thread. Slams head against desk

Thanks though.


#4

Haha that's the way these things go. Glad you were able to figure it out on your own!


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.