Part of the Whole


#1


https://www.codecademy.com/courses/python-beginner-en-qzsCL/1/4?curriculum_id=4f89dab3d788890003000096

erorr messages:

Oops, try again. get_class_average([alice]) returned 35.35 instead of 91.15 as expected

I keep on getting the same error message


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

print  get_letter_grade(get_average(lloyd)) 

students = ["lloyd","alice","tyler"]
def get_class_average(students):
    results = []
    for student in students: 
        results.append(get_average(student))
    return average(results)


#2

If you do the math manually, do you get 91.15? If not, then you probably need to read the instructions again.
If you get 91.15, and you watched another person do the math but they arrive at 35.35, would you be able to say where they went wrong?
Observe what it's doing and compare to how you would do it. Adjust the code where it's going wrong.


#3

thanks.

lol.. the only thing which was wrong was that at the beginning somehow when I returned the get_average that I had tests*0. instead of tests*0.6

thanks


#4

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