Student Becomes teach 7/9 (python)


#1




Oops, try again. get_letter_grade(90) returned 'B' instead of 'A' as expected.


Its running and I've tried my variation 1st, and then I tried three different variations of other people but I get the same results.
This last part of the code: get_letter_grade(lloyd)

def get_class_average(student):
result=[]
for item in student:
result.append(get_average(item))
return average(result)

students = [lloyd, alice, tyler]
print get_class_average(students)
print get_letter_grade(get_class_average(students))


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(sum(numbers))
    return total/len(numbers)
    
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    
    homework = homework * 0.1
    quizzes = quizzes * 0.3
    tests = tests * 0.6
    return homework + quizzes + tests
    
def get_letter_grade(score):
    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(lloyd)

def get_class_average(student):
    result=[]
    for item in student:
        result.append(get_average(item))
    return average(result)
    
students = [lloyd, alice, tyler]
print get_class_average(students)
print get_letter_grade(get_class_average(students))

Thank You everybody!!!


#2

This needs to be

if score >= 90:

because if they pass the argument 90 to the get_letter_grade function, then it will return B, when it should be A. :slight_smile:


#3

I just figured that out after I posted this. Thats the type of ish that will make you quit programming all together......


#4

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