#sample solution
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(numList):
sum = 0
for number in numList:
sum += number
return (sum/len(numList))
def getAverage(studDict):
homeworkAve = average(studDict['homework'])
quizAve = average(studDict['quizzes'])
testAve = average(studDict['tests'])
weightedAve = (0.1*homeworkAve)+(0.3*quizAve)+(0.6*testAve)
return weightedAve
print getAverage(Alice)
Is that the actual answer? I tried it the just said"Make sure you have getAverage defined".
ReplyDelete