Part of the whole


#1

i am facing this error again and again even though the function that it is asking for was made in the previous question


#3

Hi try to remove print get_average(lloyd)


#4

Is the get_average() function still in your code? If it's not in your code anymore it wont be found even if you defined it in the previous section.


#5

This is my code:

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


#6

And this is the message I keep getting if its any help

Oops, try again.
get_class_average([alice]) resulted in an error: append() takes exactly one argument (0 given)

#7

Hi try to pur get_average(student) inside .append() like that

results.append(get_average(student))

#8

Thank you so much it worked and I understand my mistake :grinning:


#9

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


#10

Boa noite, por favor atente aos detalhes:
1°) O exercício pede = ( Você pode esperar que students seja uma lista contendo seus três estudantes) , e antes ( Defina uma função chamada get_class_average com um argumento students).
É só uma questão de inversão, pois o código é o seguinte:

students=[lloyd,alice,tyler]

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

Obs.: students, pior ser uma lista, deve ser criada antes da função.


#11

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]
}
class_list = [lloyd, alice, tyler]

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(student["tests"])
homework = homework * 0.1
quizzes = quizzes * 0.3
tests = tests * 0.6
return homework + quizzes + 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"

def get_class_average(students):
results = []
for students in class_list:
results.append(get_average(students))
return average(results)
what am i doing wrong

Oops, try again. get_class_average([alice]) resulted in an error: global name 'student' is not defined


#12

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)
avg = float(total)/ len(numbers)
return avg

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

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"

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

This is what I did, but for your code maybe try inserting class list inside get_class_average() and I think it should be student not students in your for loop.