How is everybody doing?


#1

I'm stuck and don't know what's wrong!
Could you guys take a look at it and tell me what to fix?

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


def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
return 0.1 * homework + 0.3 * quizzes + 0.6 * 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):
esults = []
for student in students:
get_average(student)
results.append(get_average(student))
return average(results)


print get_class_average(students)
print get_letter_grade

Thanks! :grin:


#2

@papayabubble: You're trying to call the function get_letter_grade() but you're not using the parentheses nor passing a value since your function definition has one argument.

def get_letter_grade(your_arg_here)

#3

thank you so much for your help :relaxed:


#4

I fixed that, but now there's something wrong with:
print get_class_average(students)
It's saying:
:rotating_light: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
Can someone help me?


#5

@papayabubble: On the code you've posted above, you're using esults as your list on the function get_class_average and you're trying to use a list named results.
If you haven't fixed that yet, or fixed it already, and your code is still giving errors, I'd suggest to refresh the page and execute again.
If none of those steps work, post your edited code so we can take a look at it.


#6

Refreshing didn't work, so here's my full code:

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

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
return 0.1 * homework + 0.3 * quizzes + 0.6 * 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 student in students:
results.append(get_average(student))
return average(results)

print get_letter_grade(get_average(lloyd))
print get_class_average([lloyd, alice, tyler])


#7

@papayabubble: I've tested your code and it prints out the correct output, B and 83.8666666667.
I'd suggest to get your code, copy and paste into another compiler, such as repl.it, and execute your code.
After checking everything was printed just like expected, copy and paste back to your lession.


#8

Thank you so much for all your help. I think that its an error on Codecademy's side because on repl.it it worked but when I copied it to the lesson again it gave me the same error message.
Do you know if I can inform the Codecademy team without calling them?


#9

Could you re-attempt this line in a different way? How can you refer to the list of these three without making a literal list?

The instructions say:

print out the result of calling get_class_average with your students list.

But your code doesn't have a list called students.


#10

@papayabubble: Just like @james.rhea mentioned, you were supposed to create a list called students.
If those were the instructions and you didn't follow them, even if you come up with the correct output, you won't pass.


#11

Thank you so much @g4be and @james.rhea I finally passed :relaxed: with this as my code:

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

def get_average(students):
homework = average(students["homework"])
quizzes = average(students["quizzes"])
tests = average(students["tests"])
return 0.1 * homework + 0.3 * quizzes + 0.6 * tests

students = [lloyd, alice, tyler]

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 student in students:
results.append(get_average(student))
return average(results)

print get_letter_grade(get_average(lloyd))
print get_class_average([lloyd, alice, tyler])