Part of a whole


#1

I triggered an error for the problem child Alice as well. Oops, try again. get_class_average([alice]) should return a number. I only wrote enough code to define the def get_class_average(students): and results = []. I couldnt ever shake Alice even when just checking for indentation.


Part of a Whole
#2

i shook the alice error. Now I have a syntax error. The chevron points to the return but I have return directly under for in a for block statement. Typed and re-typed. Not sure what is invalid about return.

return average(results)
^
SyntaxError: invalid syntax


#3

def average(numbers):
total = sum(numbers)
total = float(total)
result = total/len(numbers)
return result
def get_average(student):
homework = average(student[“homework”])
quizzes = average(student[“quizzes”])
tests = average(student[“tests”])
return 0.1homework + 0.3quizzes +
0.6*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"
result = get_average(lloyd)
get_letter_grade(result)
def get_class_average(students):
results = []
for student in students:
res = get_average(student)
results.append(res)
return average(results)
#this is the working code in the most simpified form…Thank you


#4

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