lloyd = {
"name": "Lloyd",
"homework": [90, 97, 75, 92],
"quizzes": [88, 40, 94],
"tests": [75, 90]
}
alice = {
"name": "Alice",
"homework": [100, 92, 98, 100],
"quizzes": [82, 83, 91],
"tests": [89, 97]
}
tyler = {
"name": "Tyler",
"homework": [0, 87, 75, 22],
"quizzes": [0, 75, 78],
"tests": [100, 100]
}
def average(stuff):
return sum(stuff)/len(stuff)
def getLetterGrade(score):
score = round(score)
if score >= 90: return "A"
elif 90 > score >= 80: return "B"
elif 80 > score >= 70: return "C"
elif 70 > score >= 60: return "D"
elif 60 > score: return "F"
def getAverage(kid):
bar = average
return bar(kid["homework"])*.1 + bar(kid["quizzes"])*.3 + bar(kid["tests"])*.6
students = ["lloyd","alice","tyler"]
#takes students list
def getClassAverage(list, total = 0):
for x in list:
total += getAverage(x)
return total / len(list)
#takes students list
def classAvgFull(list):
print getClassAverage(list)
print getLetterGrade(getClassAverage(list))
classAvgFull(students)
老实说,我只是无法弄清楚我在哪里出错了。任何帮助将不胜感激。我敢肯定这只是简单的事情。非常非常开始我的学习,使用codeacademy.com提前谢谢你!