# Part of the whole

#1

<do not remove the t

``````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 = float(sum(numbers))
result = total / float(len(numbers))
return result

def get_average(student):
lloyd_homework=average(student['homework'])
lloyd_quizzes=average(student['quizzes'])
lloyd_tests=average(student['tests'])
lloyd_average_score=0.1*lloyd_homework+0.3*lloyd_quizzes\
+0.6*lloyd_tests
return lloyd_average_score

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

score_lloyd=get_average(lloyd)

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

return score``````
``````

hree backticks below>``````

``Replace this line with your code.``

#2

from the instructions:

Finally, return the result of calling `average()` with `results`

you return scores instead of what the instructions ask for? `results` contains the average for each student, so you want to return the average of this list, so you have the class average

Also, a function ends the moment a return keyword is reached. This currently happens in the first iteration of your loop, so the loop breaks has only done one iteration. Place return outside the loop so the whole loop can run.

#3

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