# Student Becomes the Teacher 5/9

#1

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):
return sum(numbers) // len(numbers)

def get_average(student):
return (0.1 * average(student["homework"]) + 0.3 * average(student["quizzes"]) + 0.6 * average(student["tests"]))

Oops, try again.
Make sure you converted the total or the length to a float before
the division - average([3, 0]) returned 1 instead of 1.5 as expected.

I'm not sure where the problem is?

#2

for 5/9 this is all you need after the students dictionaries.

``````def average(numbers):
total = float(sum(numbers))/len(numbers)

like so

``````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))/len(numbers)

#3

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

numbers = 0.0
def average(numbers):
total = sum(numbers)
total = float(numbers) / 2
total = len(numbers)

Oops, try again.
average([3, 0]) resulted in an error: float() argument must be a string or a number

I tried a different way and got the above error as well.

#4

only thing you need to fix is to take the total and change it to a float which is done by total = float(total)
Also it wants you to divide the total by the length of numbers, so why put a 2 there?

you can do
total = total / len(numbers)
or
total /= len(numbers)

``````numbers = 0.0
def average(numbers):
total = sum(numbers)
total = float(total)
total /= len(numbers)