Sending a letter


#1



at first it was passing as correct, but it was not printing the letter grade. I made a few changes and this is where I am now. I have looked at quite a few posts on this issue and I cannot identify where I am going wrong. I have tried the float,total 3 different ways, still same result.

Traceback (most recent call last):
File "python", line 48, in
File "python", line 31, in get_average
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'


I would like to see a Letter grade.


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


#2

i think you need to

print get_letter_grade(get_average(lloyd))

EDIT: I lied, there's a lot more going on, let me take a look at it.


#3

you need to return total, just stating return doesn't do anything.

you need to return score, and take away print get_average(), you don't want to call the function from inside the function, it will never stop.

same here, get rid of the line that you print get_letter_grade()


#4

both your average and get_average return None, this:

return

is the same as:

return None

revisit the previous exercises to see what you need to return for average and get_average

also ensure function calls are outside the function


#5

if score >= 90:
return "A"
elif score >= 80 and score <90:
return "B"
elif score >= 70 and score <80:
return "C"
elif score >= 60 and score <70:
return "D"
else:
return "F"
print get_letter_grade()
this is were u get wrong. You dont need to do "and score < 80" or "and score < 90". i made the same mistake at first. actually the computer will check the ifs one by one. If the first matches then it does matter the second if. It will just follow the return command.


#6

True, you don't need and, but you can (if you want) still use it.


#7

Well i know that it works but in learning python here. I found that an error would be encountered


#8

No error. Even though the way they did it was not the best, it's not making a difference, so we didn't mention it as an issue.


#9

Thanks all, I reviewed the return functions and cleaned a few things up. It seemed a bit clearer after I took a break.


#10

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