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先謝謝您!爲什麼這給我的錯誤字符串索引必須是整數?
那麼......哪條線麻煩你了? – satoru 2013-05-14 02:19:15
你的意思是做'酒吧*(小孩[「家庭作業」])*。1'代替'酒吧(小孩[「家庭作業」))*。1'嗎? – karthikr 2013-05-14 02:19:43