Im lost specifics would be welcomed!


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

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

def get_letter_grade(score):
if score >= 90:
return "A"
elif score >= 80:
return "B"
elif score >= 70:
return "C"
elif score >= 60:
return "D"
else:
return “F”

get_letter_grade(get_average(lloyd))

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

return average(results)

---- File “python”, line 53
return average(results)
^
SyntaxError: invalid syntax


#2

Hi @scriptsurfer78374,

A SyntaxError reported at the beginning of a line is often a result of a problem on the previous line of code.

Here’s the statement above the one where the SyntaxError was reported …

    results.append(get_average(student)

#3

results.append(get_average(student)
results.append(get_average(student)) <----- File “python”, line 51
SyntaxError: ‘return’ outside function

i dont understand what it means not inside function?

effectively,

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


#4

There may be something missing in this statement on line 50 …

    results.append(get_average(student)

#5

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

this is my function after playing about abit although i reached another error,

get_class_average([alice]) resulted in an error: list indices must be integers, not str


#6

Here, you are passing the entire class_list object to the get_average function where you should instead be passing an individual student to the function …

        results.append(get_average(class_list))

#7

its been corrected adn its let me through tyvm for the assist


#8