# 6. just weight and see

#1

what am i doing wrong??

``````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(total)
total = total / len(numbers)
def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests  = average(student["tests"])
return (get_average['homework']*10) + (get_average['quizzes']*30) + (get_average['tests']*60)
``````

my error message:

Oops, try again. get_average(alice) raised the following error: âfunctionâ object has no attribute âgetitemâ

#2

Hi this line

``````    return (get_average['homework']*10) + (get_average['quizzes']*30) + (get_average['tests']*60)
``````

you cantâ call the function inside itself
You already saved the average inside some variable hereâŚ

``````homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests  = average(student["tests"])
``````

04. Multiply the 3 averages by their weights and return the sum of those three. Homework is 10%, quizzes are 30% and tests are 60%.
adn the 10% of homework you should mutliply it by 0.1 the same for the others (0.3, 0.6)

#3

def get_average(student):
homework=average(student[âhomeworkâ])
quizzes=average(student[âquizzesâ])
tests=average(student[âtestsâ])
return (get_average[homework]/.1) + (get_average[tests]/.6
)+(get_average[quizzes]/.3)

#4

Hi you should read my postâŚ

#5

i did and it didnât work for me sorry

#6

can you post your update code?

#7

sure here it is
def get_average(student):
homework=average(student[âhomeworkâ])
quizzes=average(student[âquizzesâ])
tests=average(student[âtestsâ])
return(get_average[âhomeworkâ]*0.1) +
(get_average[âquizzesâ]*0.3) + (get_average[âtestsâ]*0.6)

#8

Sorry but itâs not like I alread said
this line

``````return(get_average['homework']*0.1) + (get_average['quizzes']0.3) + (get_average['tests']0.6)
``````

YOU CANĂŹT CALL THE FUNCTION INSIDE ITSELF SO THE

``````get_average['homework']*0.1
``````

Should be

``````return homework * 0.1 ...

``````

#9

iâm so sorry i did what you said and discovered that there where a problem because of a whitespace
this is the working code now it seems to be realy easy
def get_average(student):
homework=average(student[âhomeworkâ])
quizzes=average(student[âquizzesâ])
tests=average(student[âtestsâ])
return (homework0.1) + (quizzes0.3) + (tests*0.6)

#10

now there is another problem sorrly it is not working
if score >= 90:
return âAâ
elif score >=80:
return"B"
elif score >=70:
return"C"
elif score >=60:
return"D"
else:
return âFâ

#11

Remove the indent to all this part

``````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"
``````

#12

it didnât work

#13

it worked i for got to remove the first space from the def get_letter_grade

#14

YOUR CODE SHOUL BE INDENT LIKE THAT

``````def get_average(student):
....
return (homework*0.1) + (quizzes*0.3) + (tests*0.6)

if score >= 90:
return "A"
elif score >=80:
return"B"
elif score >=70:
return"C"
elif score >=60:
return"D"
else:
return "F"
``````

closed #15

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