7/9 - get_letter_grade(100) returned 'F' instead of 'A' as expected


#1

This is my code:

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]
}

# Add your function below!
def average(numbers):
        total = sum(numbers)
        total = float(total)
        total = total / len(numbers)
        return total
        
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    return 0.1 * homework + 0.3 * quizzes + 0.6 * tests
    
def get_letter_grade(score):
    score = 0
    if score >= 90:
        return "A"
    elif score >= 80:
        return "B"
    elif score >= 70:
        return "C"
    elif score >= 60:
        return "D"
    else:
        return "F"
        
get_letter_grade(get_average(lloyd))
print get_letter_grade(lloyd)

EDIT: I've already fixed it.

Had to delete score = 0.

Thought that "01. Define a new function called get_letter_grade that has one argument called score. Expect score to be a number." meant that I had to define a numeric value to 'score'.


#2

Very good...
The function-talk would then be

As the get_letter_grade function takes 1 parameter score
which is used as a variable within the FUNCTION-BODY

Now as you want to call / execute the get_letter_grade function
get_letter_grade()
and the get_letter_grade function was defined as having 1 parameter
you will have to provide 1 argument which should be a number Value
in our case that would be the return-Value of get_average(lloyd)
like
get_letter_grade(get_average(lloyd))
but
as the get_letter_grade function will return a string Value with NODisplay
we are using the print statement
like
print get_letter_grade(get_average(lloyd))

PS.
print get_letter_grade(lloyd) is NOT valid
print get_letter_grade(50) would have been valid.


#3

Thanks for clarifying it!