Part of the Whole


#1

Hi! Can anybody tell where I did wrong in the last part: calculate the whole average?

Add your function below!

students={lloyd,alice,tyler}
def average(numbers):
total=sum(numbers)
total=float(sum(numbers))
result=total/len(numbers)
return result
print result

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

def get_letter_grade(score):
if score>=90.0:
return "A"
elif score>=80.0:
return "B"
elif score>=70.0:
return "C"
elif score>=60.0:
return "D"
else:
return "F"
print get_letter_grade(average(lloyd))

def get_class_average(students):
results=[]
for students in students:
results.append(get_average(student))
return results


#2

The iterator variable is the same as the list name. Not going to work. Try,

for student in students:

Now the variable is unique and doesn't clash with anything.