Sending A Letter Bug


#1


This code returns a result of A. It should not return anything because a dict is unable to be passed through the function.


It should say - TypeError: '>=' not supported between instances of 'dict' and 'int'


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)
    return total /  len(numbers)
    
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    return sum(((.1 * homework),(.3 * quizzes),(.6 * 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'

print get_letter_grade(lloyd)


#2

@arcplayer65093,

Codecademy currently offers Python 2.7.3 in its exercises. In that version of Python, it does not constitute a TypeError to compare a dict to an int. The comparison in the if block header results in the value, True, so "A" gets returned. In Python 3.6, that comparison would raise a TypeError.

However, Codecademy's submission correctness test (SCT) should not have accepted your code because it does not use the get_letter_grade function correctly. This is a bug in the SCT.


#3

Do I need to do anything else to report it?


#4

You can report the bug in the Community > Platform Problems category.

Start a new discussion there to report it.

Be sure to supply:

Thanks :smile:


#5

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