# Weights problems

#1

My code for the Weight averaging looks like the following:
It seems to work fine, but it keeps throwing an error about Alice. I am not sure why?
Also, when I try to run this on Python 3, I get an error with the
ave_hw=get_average(student["homework"]) part, like it knows the student, but it doesn't actually match it up correctly.

import math

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 = [tyler, lloyd,alice]

def get_average(numbers):
total =(sum(numbers))
Ave = float(total)/len(numbers)
return Ave

for student in students:
ave_hw=get_average(student["homework"])
ave_qz = get_average(student["quizzes"])
ave_tst = get_average(student["tests"])
total = (ave_hw*.1)+(ave_qz*.3)+(ave_tst*.6)
print student["name"]
print total

``Replace this line with your code.``

#2

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