#6 just weight and see


#1



Please hep me understand what I am doing wrong


File "python", line 31
weigted = ("homework".1) + ("quizzes".3) +("tests"*.6)
^
SyntaxError: invalid syntax


(homework*0.1)+(quizzes*0.3)+(tests*0.6)


#2

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(students["tests"]
weigted = ("homework".1)+("quizzes".3)+("tests"*.6)
return weighted


#3

can you post your full code?


#4

Hi, @revascode ,

Is there something missing here, which is the line prior to where the SyntaxError was reported? ...

tests = average(students["tests"]

Also be careful with spelling ...

weigted = (homework*0.1)+(quizzes*0.3)+(tests*0.6)
return weighted

#5

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

Thank you for helping


#6

appylpye already provided you with the solution?

look at the parentheses/brackets in this line:

tests = average(students["tests"]

#7

I fixed that and tried to add a student list.
now alice is mad

students = ["lloyd", "alice", "tyler"]  
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(students["tests"])
    weighted = ("homework"*.1)+("quizzes"*.3)+("tests"*.6)
    return weighted

Oops, try again. get_average(alice) raised the following error: list indices must be integers, not str

sorry to be a bother, I am trying to understand.


#8

def average(numbers):
    total = sum(numbers)
    total = float(total)
    total =total / len(numbers)
    return total
    
students = ["lloyd", "alice", "tyler"]  
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(students["tests"])
    weighted = ("homework"*.1)+("quizzes"*.3)+("tests"*.6)
    return weighted

still trying to post correctly


#9

students = ["lloyd", "alice", "tyler"]

alice and the others need the quotes removed so that the dicts are listed as variables, rather than strings.

There is also a problem here, with students instead of student ...

tests = average(students["tests"])

#10

this line:

students = ["lloyd", "alice", "tyler"]

the lists should hold the dictionary's. one of the dictionary is called lloyd so then in the list:

students [lloyd] # add the rest of the students

yes, you can store dictionary's in list, if you don' remember, revisit 3. put it together


#11

I feel foolish, because I am not getting it

`
def average(numbers):
total = sum(numbers)
total = float(total)
total =total / len(numbers)
return total

students = [lloyd, alice, tyler]
def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(students["tests"])
weighted = ("homework".1)+("quizzes".3)+("tests"*.6)
return weighted
'''
Oops, try again. get_average(alice) raised the following error: list indices must be integers, not str

thank you


#12

def average(numbers):
    total = sum(numbers)
    total = float(total)
    total =total / len(numbers)
    return total
    
students = [lloyd, alice, tyler] 
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(students["tests"])
    weighted = ("homework"*.1)+("quizzes"*.3)+("tests"*.6)
    return weighted

#13

this line:

tests = average(students["tests"])

you use students instead of student.

this line:

weighted = ("homework"*.1)+("quizzes"*.3)+("tests"*.6)

homework, quizzes and tests are variable, not string, don't use quotation marks


#14

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