# Get_class_average([alice]) resulted in an error:

#1

Hi, I wrote my code just like this and it returns me "get_class_average([alice]) resulted in an error: 'float' object is not callable"

I have no idea of what's going on

def average(numbers):
return float(sum(numbers)) / len(numbers)

def get_average(student):
homework = float(sum(student['homework'])) / len(student['homework'])
quizzes = float(sum(student['quizzes'])) / len(student['quizzes'])
tests = float(sum(student['tests'])) / len(student['tests'])
return 0.1 * homework + 0.3 * quizzes + 0.6 * tests

if score >= 90:
return 'A'
elif score >= 80:
return 'B'
elif score >= 70:
return 'C'
elif score >= 60:
return 'D'
else:
return 'F'

def get_class_average(students):
results = []
for student in students:
average = get_average(student)
results.append(average)
return average(results)

Part of the whole
#2

You have two big issues with your code, the first can be found here:

def get_average(student):
homework = float(sum(student['homework'])) / len(student['homework'])
quizzes = float(sum(student['quizzes'])) / len(student['quizzes'])
tests = float(sum(student['tests'])) / len(student['tests'])
return 0.1 * homework + 0.3 * quizzes + 0.6 * tests

Why are you doing all of those extra operations to get the average. You already defined a way to get the average, it's called average(). Therefore, if you want to get the average for homework, you would do this:

homework = average(student["homework"])

The same can be done for quizzes and tests.

The second issue has nothing to do with what's in your code; It's more of what isn't in your code. Your code appears to be missing the student dictionaries...

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