# Sending a letter printing the wrong grade

#1

lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}

def average(numbers):
total = sum(numbers)
total = float(total)
total = total / len(numbers)

def get_average(student):
homework = average(student["homework"])*0.1
quizzes = average(student["quizzes"])*0.3
tests = average(student["tests"])*0.6
return homework + quizzes + tests

if score >= 90:
return "A"
elif score >= 80:
return "B"
elif score >= 70:
return "C"
elif score >= 60:
return "D"
else:
return "F"

for some reason this print "A" even thought lloyd's grade should be a "B" why is it not running the functions i have written and why is it assigning the letter "A" to lloyd?

#2

the get_letter_grade only converts the average grade of a student into a letter grade, so first you need to calculate lloyds average grade (using `get_average()`)

#3

could you please show me how that would be done? im having trouble understanding even though the lesson says its correct and lets me move on to the next lesson.

edit- i was under the impression that just writing "print get_letter_grade(lloyd)" would make it perform all necessary functions

#4

no, you first need to calculate the average of lloyd (`get_average(lloyd)`), this value we need to supply for get_letter_grade

#5

im really sorry but i still dont get it you're telling me to use the get_average function to get a value and then use it in the get_letter_grade function, i know that i have to write get_average(lloyd) but how to i then translate that into the get letter grade function? either way my main problem is if i clearly haven't done that yet why is the lesson allowing me to move on and telling me what ive done is correct if it clearly isnt

#6

well, you can store the result of `get_average(lloyd)` in a variable and pass this as value into calling get_letter_grade, or pass `get_average(lloyd)` directly as value when calling `get_letter_grade()`

calling the get_letter_grade() is not part of the instructions, so its not validated

#7

ive now added score = get_average(lloyd) above the get_letter_grade function and now its printing the correct grade, i actually feel like quite a dummy having missed that but thanks for explaining it. im intrigues tho what exactly is it doing when it prints "A" if i dont have a lloyds average set to score, it it just assigning a random number for the purpose of the lesson or am i missing something. again thanks for the help

#8

good you figured out

I don't know why the wrong letter grade was printing

#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.