Just Weight and See


#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]
}
def average(numbers):
    total = sum(numbers)
    total = float(sum(numbers))/len(numbers)
    return total
    
def get_average(student):
    homework == (average(student["homework"]),
    quizzes == (average(student["quizzes"]),
    tests == (average(student["tests"]),
    grade = ((0.10 * homework) + (0.30 * quizzes) + (0.60 * tests))
    return grade

    File "python", line 29
    return grade
         ^
SyntaxError: invalid syntax

I am very confused about what I am doing wrong. 
If someone could please explain that would be very helpful! Thanks!


#2

The first three lines of the get_average function are boolean expressions when they should be assignment statements.

homework = average( ... )

There are a lot of parens that are not needed. In fact none of them are except in the function calls.

Commas are only used to separate items in a reference object, (list, tuple, set, dictionary) or a parameter list.


#3

Okay, I got it. Thank you!


#4

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