Can any one help me to find solve these problem in lst two lines


#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(total)
total=total/len(numbers)
return total
student=[lloyd, alice, tyler]

Add your function below!

def get_average(student):
homework=0.1*average(student["homework"])
quizzes=0.3*average(student["quizzes"])
tests=0.6*average(student["tests"])
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"
print get_letter_grade(get_average(lloyd))

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

print get_class_average(students)
print get_letter_grade(get_average(students))


#2

Did you mean,

get_letter_grade(get_class_average(students))

#3

ya i hve tried that one to but it showing error like::

Oops, try again.
One of the following is missing or broken when we tried to use it:
alice, lloyd, tyler, students, get_class_average, get_letter_grade

i am unable to unedrstand that


#4

I mean can you just copy the error?


#5

you need to use for student in students: to go through every student and then you want to get his average by making a veriable, I called it result = get_average(student) so for each student it makes his average then you results.append(result)
tell me if you didn't understand


#6

ya i get that but after doing these also it showing the same error:::
Oops, try again.
One of the following is missing or broken when we tried to use it:
alice, lloyd, tyler, students, get_class_average, get_letter_grade

students=["Llyod","Alice","Tyler"]
def get_class_average(students):
    results=[]
    for student in students:
        results.append(get_average(student))
    return average(results)
    
print get_class_average(students)
print get_letter_grade(get_class_average(students))

and also it is giving the error like:::

Traceback (most recent call last):
File "python", line 53, in
File "python", line 50, in get_class_average
File "python", line 27, in get_average
TypeError: string indices must be integers, not str


#7

Can I see your indents? press Cntl + shift + c to paste ur code


#8

but the students list should hold the dictionary's, not string name representation.


#9

ooooh thnk u for helping me. Now its runs fine.
thnku once again
and today is diwali festival here so wish u and codeacademy a very lighting hapy diwali


#10

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