# 8/9 Part of the Whole

#1

I'm so frustrated!!! This code is not working!

``````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):
#sum of the numbers
total = sum(numbers)
#making the integer a float
total = float(total)
#finding average
total = total / len(numbers)
#storing it until function is called

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

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
return homework * 0.10 + quizzes * 0.30 + tests * 0.60

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)``````

#2

Codecademy says, "Oops, try again. There seems to be something wrong with your code, see the console window for the error message!"

#3

The console says, " File "python", line 61 SyntaxError: 'return' outside function"

#4

I think the console gives a fair error message, this is your get_class_average function:

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

oops, return is not inside the function, you might want to change the indent of the return statement on the line below:

``````#re-indent me
return average(results)``````

#5

Its ok, this code jus worked 4 me:

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

But tks anyway.

#6

This code worked for me, but I still dont get how you print it

``````if score >= 90:
return "A"

elif score >= 80:
return "B"

elif score>= 70:
return "C"

elif score >= 60:
return "D"

else:
return "F"``````

#7

You can call the function with a print statement:

``print get_letter_grade(80)``

to get it printed

#8

Oh okay. Thanks for the help