Average


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

# Add your function below!
def average(numbers,):
    total=sum(numbers)
    total=float(total)
    total=float(total)/len(numbers)
    return total
def get_average(student,):
    homework=average(student["homework"])
    quizzes=avarage(student["quizzes"])
    tests=avarege(student["tests"])
    weights=homework*0.1+quizzes*0.3+tests*0.6
    return weights

I read other topic but I couldnt do this exercise.Where is my mistake ?


#2

Here,

and here,

for a start. The commas may be tripping up the SCT. Python doesn't seem to object so must be ignoring them (no effect).

>>> def foo(bar,):
	return bar

>>> foo("foobar")
'foobar'
>>>

Try removing the commas and see if it passes.


#3

check how to spell average + @mtf = answer


#4

These are the lines our young colleague is referring to.

We might add,

    total=float(total)
    total=float(total)/len(numbers)

The second line above does not need to be declared a float, again. It is a float.

total = total / len(numbers)

#5

thank you very much.english isnt my mother language ,so sometimes my spelling can be wrong :frowning:


#6

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