6/9 whats wrong with alice?


#1

the error box keeps coming up with this

Oops, try again. get_average(alice) raised the following error: unsupported operand type(s) for +: 'int' and 'str'

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)
total = float(total)
total = total / len(numbers)
return total
get_average = lloyd, alice, tyler
def get_average(student):
homework = average(["homework"])
quizzes = average(["quizzes"])
tests = (["tests"])
return homework*0.1, quizzes*0.3, tests*0.6

thank you to any one in advance!


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

It appears the + \ is essential


#3

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

this is what you meant right? but this error still pops up

Oops, try again. get_average(alice) raised the following error: unsupported operand type(s) for +: 'int' and 'str'

it is indented properly even though it doesnt look like it


#4
tests = average(student["tests"])

as oppose to what you currently have:

tests = (["tests"])

could make a difference

EDIT: do the above for all of your variables


#5

thank you! i dont know how i over looked that! thank you!


#6

in a normal setting would this work as well

homework = 0.10 *average(student[homework]) 
quizzes = 0.30 * average(student[quizzes]) 
tests = 0.60 * average(student[tests])

#8

I am still a beginner myself but logically that looks like it should work.


#9

def get_average(student):
homework = 0.10 * average(student["homework"])
quizzes = 0.30 * average(student["quizzes"])
tests = 0.60 * average(student["tests"])
return homework + quizzes + tests

HELP I'm stuck here : I've tryed everything and ALWAYS I've got the same error:

Oops, try again.
get_average(alice) raised the following error: unsupported operand type(s) for *: 'float' and 'NoneType


#10

You are trying to multiply a float with something of none type. By converting the student average to a float (As demonstrated below) will fix this error. However this is not the problem I believe that the probable reason that it thinks that what average is returning is a Null type is because in your average function you are printing the total rather than returning it.

homework = 0.10 * float(average(student["homework"]))
quizzes = 0.30 * float(average(student["quizzes"]))
tests = 0.60 * float(average(student["tests"]))
return homework + quizzes + tests


#11

Thank you! Makes much more sense now!