Just Weight and See 6 error


#1



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


Oops, try again. get_average(alice) returned 1438.23 instead of the expected 91.15

For it to run properly


Replace this line with your code. 
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]
}

# Add your function below!
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.6)


#2

Hello

The last line - return. This is where you are getting your error from.

The example given in this lesson -

return 0.9 * average(cost["apples"]) + \0.1 * average(cost["bananas"])......
It starts with a number.

I will help you with the first bit -
return 0.1 * homework.......

Also parentheses is unnecessary. The lesson asks that you - Multiply the 3 averages by their weights and return the sum of those three. Homework is 10%, quizzes are 30% and tests are 60%.

However keep the example given in this lesson in mind, because later in the lessons you will need to enter something similar to that example.

Hope that helps.


#3

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