# Part of the whole - I don't understand!

#1

Code seems to be right, i pass the lesson, but I have a question:

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

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

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

Here I don't create a class_list with lloyd alice and tyler but in output I can see the class average, but on python idle the same code doesn't work without a list.
Is this a bug or something else?

#2

There is a little oddity in Codecademy. It maintains a memory cache that may store some objects between exercises.

In Exercise 3: Put It Together, you created this statement ...

students = [lloyd, alice, tyler]

Codecademy may still remember that students variable from a previous exercise. To make your program technically correct, restore that statement in your code.

If you are using Python 3.x in your copy of IDLE, remember that print is a function, requiring parentheses.

#3

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