# Part of the Whole getting 83.66667 instead of 91.15

#1

Getting 83.8666666667 instead of what they are expecting: 91.15

I'm really just not sure what the issue with my code is

``````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]
}

def average(numbers):
total = sum(numbers)
total = float(total) / len(numbers)

def get_average(student):
return 0.10 * average(student["homework"]) + 0.30 * average(student["quizzes"]) + 0.60 * average(student["tests"])

if score >= 90.0:
return "A"
elif score >= 80 and score < 90:
return "B"
elif score >= 70 and score < 80:
return "C"
elif score >= 60 and score < 70:
return "D"
else:
return "F"

class_list = [lloyd, alice, tyler]

def get_class_average(students):
results = []
for students in class_list:
results.append(get_average(students))
return average(results)
print get_class_average(classs)``````

#2

Do the math manually and see which number you agree with.
If you disagree with your program then the next thing to do is find out what it did - you can do this by adding prints for each action it carries out and then comparing the output to how you'd be doing it.

If you agree with the program then you wrote the code correctly to your understanding, but your understanding is wrong. You can then re-read the instructions and if that still doesn't help then you've got a much more specific question to ask where you can describe what you understand and someone can easily point out where you go wrong similiar to how you'd otherwise point out how your program's prints are going wrong

#3

I did the math, I got 83.66666667, but other people have passed this, so maybe I did something wrong? I keep looking through it and can't see any issues, maybe I'm just calculating for the wrong thing?

#4

I believe that the error message from codecademy says what the input is

#5

Consider your result of `get_class_average("elephant")`

#6

says elephant is not defined, which.. I would agree with.
apologies, last line of my code print get_class_average(classs) should be get_class_average(class_list)

#7

No, it doesn't, you wrote something else, "elephant" is a value, it is a definition by itself, it can't be undefined

#8

#9

oh duh, didn't have the quotations. Now I'm uber confused.

#10

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