8- Part of the whole


#1

When I run it, it always comes out with an error saying "get_class_average([alice]) returned 83.8666666667 instead of 91.15 as expected"

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)
result = float(total) / len(numbers)
return result
def get_average(lloyd):
x = average(lloyd["homework"])
y = average(lloyd["quizzes"])
x = average(lloyd["tests"])
return x * 0.1 + y * 0.3 + z * 0.6
def get_average(alice):
x = average(alice["homework"])
y = average(alice["quizzes"])
z = average(alice["tests"])
return x * 0.1 + y * 0.3 + z * 0.6
def get_average(tyler):
x = average(tyler["homework"])
y = average(tyler["quizzes"])
z = average(tyler["tests"])
return x * 0.1 + y * 0.3 + z * 0.6
def get_letter_grade(score):
if score >= 90:
return 'A'
elif score >= 80:
return 'B'
elif score >= 70:
return 'C'
elif score >= 60:
return 'D'
else:
return 'F'
group = [tyler, alice, lloyd]
def get_class_average(students):
results = []
for student in group:
results.append(get_average(student))
return average(results)


#2

Hello, @wactodoin!
To be honest, I don't really know how this code could be working because I've never seen three functions with the same name and calculation, inside of it, but with the only difference each one is for a different student but hey, if that works, that's fine.
I couldn't find what might've caused, try refreshing the page and executing again or even change browsers.

Quote me if there's something else I can help you with!

Best regards,
g4be