7. Sending a Letter


#1

if score >= 90.0
return "A"
elif score >= 80.0
return "B"
elif score >= 70.0
return "C"
elif score >= 60.0
return "D"
else:
return "F"
print get_letter_grade(get_average(lloyd))

https://www.codecademy.com/en/courses/python-beginner-en-qzsCL/1/3?curriculum_id=4f89dab3d788890003000096#
File "python", line 21
def average(numbers):
^
IndentationError: expected an indented block

Does anyone see a reason why this code will not work?

Replace this line with your code.


#2

Indentation errors are very easy to fix all you need to do is indent, :smile: :sweat_smile:

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 .1 * average(student["homework"]) + \
           .3 * average(student["quizzes"]) + \
           .6 * average(student["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_average(lloyd)

#3

your return for your get_average function duplicates the function code. instead of

.1 * average(student["homework"])

you only need to code

.1 * homework

as you have defined homework as

homework = average(student["homework"])

within the function.

I am still working on the the get_letter_grade function myself, check for redundancy, you will be able to clean up your code.


#4

The code above is not mine but the first poster :grin: