#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 (float(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
def get_letter_grade(score):
if score >= 90:
return "A"
elif score < 90 and score >=80:
return "B"
elif score < 80 and score >=70:
return "C"
elif score < 70 and score >=60:
return "D"
elif score < 60:
return "F"
print get_letter_grade(getAverage(Lloyd))
I've put the exact same answer and it still say: Oops, try again! Make sure average returns a float!
ReplyDeleteany solutions?
Thanks. Updated the code to reflect the changes in Codecademy's exercises.
ReplyDeleteNeed to indent the get_letter function:
ReplyDeletedef get_letter_grade(score):
if score >= 90:
return "A"
elif score < 90 and score >=80:
return "B"
elif score < 80 and score >=70:
return "C"
elif score < 70 and score >=60:
return "D"
elif score < 60:
return "F"
print get_letter_grade(getAverage(Lloyd))
Indent the returns
ReplyDelete