# 8/9 Part of the Whole

#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
<In what way does your code behave incorrectly? Include ALL error messages.>
My code seems right, but for some reason get_class_average([alice]) returns as an infinite decimal instead of 91.15. When printing get_average(alice), however, it does print 91.15. The error message reads: âOops, try again. get_class_average([alice]) should return a numberâ.
<What do you expect to happen instead?>

```python

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)
average = total / len(numbers)
return average

def get_average(student):
homework = average(student[âhomeworkâ])
quizzes = average(student[âquizzesâ])
tests = average(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:
results.append(get_average(student))
return results

``<do not remove the three backticks above>``

#2

`get_class_average` should return an average of all the averages in the student list.

#3

@mattisse

In your "def get_class_average(students) " must return the average.
hint hint - use your "average function "

#4

hi all this is my code and i stucking here because am newbie

#5

hi all this is my all code here

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)
total = total / len(numbers)
def get_average(students):
homework=average(students[âhomeworkâ]) * .10
quizzes=average(students[âquizzesâ]) * .30
tests=average(students[âtestsâ]) * .60
return homework+quizzes+tests
if score >= 90:
return âAâ
elif score >= 80:
return âBâ
elif score >= 70:
return âCâ
elif score >= 60:
return âDâ
else:
return âFâ

students = [lloyd, alice, tyler]
def get_class_average(students):
results =
for student in students:
results.append(get_average(student)

#6

HI you didnât close append()

#7

lool i miss him sorry bro

#8

It does do this, by filling the empty results list with the return of get_average(student).

#9

My question is about why get_class_average([alice]) isnât returning a number while the function get_average(alice) isâŚ

#10

Well I âsolvedâ it without really solving anything. Thanks!

#11
``````I know this is after you've Solve it but this might help look at the last function

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(d):
homework = average(d['homework']) *0.1
quizzes = average(d['quizzes']) *0.3
tests = average(d['tests']) *0.6

return homework + quizzes + tests

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