# Just Weight and See

#1

Hi Guys,

I’m getting the following error when running my code:

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

I’m not sure why the average is incorrect, as i havent changed any of the values in the dictionaries.

Was wondering if anyone could see whats wrong.

Thanks

``````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)

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
return (homework * 0.1) + (tests * 0.3) + (quizzes * 0.6)
``````

#2

Look here:

Reread the instructions (number #4 mainly).

#3
``````print ("Lloyd: %s" % get_average(lloyd))
print ("Alice: %s" % get_average(alice))
print ("Tyler: %s" % get_average(tyler))
``````

Your results should look something like this…

``````Lloyd: 80.55
Alice: 91.14999999999999
Tyler: 79.9
``````

#4

Thanks. Such a silly mistake

#5

I had a teacher once who delighted in saying, “There is no grade for effort if you don’t follow the instructions. You get zero on that one.”

#6

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