#1

}

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

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

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 results in students:
results.append(get_average(student))
return average(student)
print get_class_average(class_list)

``Replace this line with your code.``

#2

#3

return results(student) i made it to this? then i get this error. Oops, try again. One of the following is missing or broken when we tried to use it: alice, lloyd, tyler, students, get_class_average, get_letter_grade

#4

You are returning the average of results, right?

``return average(results)``

Sorry for a quick approach, I have to leave the forums for this day.

#5

`results` is a value, not a function. Use the average function to arrive at the final return value...

``return average(results)``

#6

thnx guys but if i use: return average(results) i get the same error

#7

``````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(student):
homework = homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
return homework * 0.1 + quizzes * 0.3 + tests * 0.6

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 results in students:
results.append(get_average(students))
return average(results)
students = [lloyd, alice, tyler]
print get_class_average(class_list)

#8

Those three lines need to be unindented so they are not inside a function block.

#9

thnx for the quick reply when i put them all the way back at the side it gives this: Traceback (most recent call last):
File "python", line 52, in
File "python", line 48, in get_class_average
AttributeError: 'dict' object has no attribute 'append'

#10

Did you mean to write 'students' and not 'class_list'?

Did you mean to write, `student` and not `students`?

#11

frankly im so confused about this lesson. i think the first one should be student and not class_list but im not sure

#12

I had the same problem. Your logic is correct. Just create a list: students = [lloyd, alice, tyler]. Then in your print statements input students

#13

aprreciate the help but i already have that man

#14

To get a class average we need to pass the entire class list (`students`) to the function. The list is iterated over, one `student` at a time, during which we call the average() function on each `student`, in turn.

#15

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