Quotes help make search much faster. Example: "Practice Makes Perfect"

Wednesday, November 28, 2012

Codecademy: Just Weight and See


#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)

1 comment:

  1. Is that the actual answer? I tried it the just said"Make sure you have getAverage defined".

    ReplyDelete


This is an example of scrolling text using Javascript.

Popular Posts