How Is Everybody Doing?


#1

def average(numbers):
total = float(sum(numbers))
return total/len(numbers)

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])

return 0.1 * average(student["homework"]) + \
0.3 * average(student["quizzes"]) + \
0.6 * average(student["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"

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

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]
}

print average(lloyd)
print get_average(lloyd)
print get_letter_grade(get_average(lloyd))

print average(alice)
print get_average(alice)
print get_letter_grade(get_average(alice))

print average(tyler)
print get_average(tyler)
print get_letter_grade(get_average(tyler))

students = [lloyd, alice, tyler]
print get_class_average(students)

Well, I've checked all the other threads on this topic, applied all those fixes. Still no luck. I'm out of ideas - is there some sort of malfunction going on with the web site?


#2

Formatting gets lost when I copy and paste, BTW.


#3

Hi read this about how to format the code


#4

Thanks for the quick reply. It didn't help.

This is code I copied and pasted from the last time I took the course, 8 months ago. Worked fine then, no reason for it to not work now.


#5

Hi here your code, I will just put it in oder...

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]
}

2

def average(numbers):
    total = float(sum(numbers))
    return total/len(numbers)

3

def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])

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

4
This part at I add the print get_letter_grade(get_average(lloyd)) from the lesson 7. Sending a Letter

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"
print get_letter_grade(get_average(lloyd))

  1. Here you should add the array of your students .....students = [lloyd, alice, tyler] on top of this part like that

students = [lloyd, alice, tyler]

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

Then in the last lesson 9. How is Everybody Doing? they aske you to do that

1 Finally, print out the result of calling get_class_average with your students list. Your students should be [lloyd, alice, tyler].

from your code its this part

students = [lloyd, alice, tyler]
print get_class_average(students)

2 Then, print the result of get_letter_grade for the class's average.
and this part you son't need it.

print get_letter_grade(students)

Like you can see I add some part but you code was fine but it was in a wrong order.
Hope that could help YOu