6 Just Weight and See


#1



https://www.codecademy.com/courses/python-beginner-en-qzsCL/1/2?curriculum_id=4f89dab3d788890003000096


Error = Make sure you have defined get_average


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


#2

Strange. It runs on mine and it doesn't look like anything is off. Perhaps refresh and try again? Or try a different browser.


#3

Shows the same error message, here's the whole code

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

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


#4

Still passes on mine. I'm using Chrome.


#5

Same here, tried it on edge


#6

Error message reads - Oops, try again. Make sure you have defined get_average


#7

Perhaps your indentation is off on your average function? Does it look like this?:

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 (homework * 0.1) + (tests * 0.6) + (quizzes * 0.3)

#8

Got it, incorrect indentation in def get_average, thanks for the help.


#9

thx it really helps for me.... :slight_smile:


#10

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