Sending A letter


#1


soo i got the code to pass multiple ways but im trying to figure out if this code is accurate or not


Replace this line with your 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)
    average = total / len(numbers)
    return average
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    return 0.1 * average(student["homework"]) + 0.3 * average(student["quizzes"]) + 0.6 * average(student["tests"])
def get_letter_grade(score):
    if score >=90:
        return "A"
        print "A"
    elif score >=80:
        return "B"
        print "B"
    elif score >=70:
        return "C"
        print "C"
    elif score >=60:
        return "D"
        print "D"
    else:
        return "F"
        print "F"
    
get_letter_grade(get_average(lloyd))
print get_letter_grade(get_average(lloyd))


#2

Hi @arcninja26143,

Execution of a function terminates right after a return statement is executed with the function. Therefore, the print statement in a block such as this one never gets executed ...

   if score >=90:
        return "A"
        print "A"

The best tjhing to do here would be to remove all the print statements from the get_letter_grade function. Then, to display a result, you only need to do this ...

print get_letter_grade(get_average(lloyd))

#3

ok anything else i should adjust


#4

You don't need this statement ...

get_letter_grade(get_average(lloyd))

Everything else looks fine.


#5

ok thank you for view my code


#6