Help with 11-8 pleeease


#1



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

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

help what is wrong i no i skrewed up soo manny things


#2

Well, first off, I believe you meant results = [] not results [].


#3

okay, thanks. anything else?


#4

Secondly, instead of student in class you need student in students. Since you use students in your list these both correspond right here (and like you have in your def get_class_average statement). However, you don't seem to have a list at all of the students in an array form. I would suggest adding that somewhere if not just to have it as a visual. Also, results in your last return statement does not need to be in [] at all. Get rid of those.


#5

awesome! is that it?


#6

also i updated it and i am still getting an error.


#7

Mind posting your updated code? I will copy and paste it into my lesson and look at it again!


#8

i did


#9

What's the error message you're getting with your updated code?


#10

Oops, try again. get_class_average([alice]) resulted in an error: unsupported operand type(s) for +: 'int' and 'str'


#11

Try moving your return statement outside of the for loop. As it is written now, it returns at the first iteration of the loop, thus ending the function.


#12

i fixed that, thanks! but i am still getting that error message


#13

can we see an updated version of your code?


#14

its there at the top. ive been updating it as you guys suggest changes :slight_smile:


#15

you should (as the instructions say) append get_average(student) to results, you append average(student) to results

get_average() calculates the average grade for a student, average() is just designed to calculate the average for a list of numbers.


#16

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