# 9/9 How is Everybody Doing? Error message befor resolving

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
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

<What do you expect to happen instead?>
I have resolved it. I am just sharing to state that all these variable or functions need to be stated to pass the test. Putting in list form:
alice
lloyd
tyler
students
get_class_average

Most people will missed out the students variable as it has been removed after exercise 5

```python

Replace this line with your 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)
avg=total/len(numbers)
return avg

def get_average(student):
homework=student[“homework”]
quizzes=student[“quizzes”]
tests=student[“tests”]

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

students=[lloyd, alice, tyler]
def get_class_average(students):
for student in students:
total=0
total=+get_average(student)
mean=total/len(students)
return mean
print get_class_average(students)

``<do not remove the three backticks above>``
4 Likes

Your answer is right . I copy and pasted it, but it is not done correctly how python would like it done, and that’s where I am getting confused. I like this academy because all the help people give on the problems, and even if I don’t understand what is going on I can compare my answer to someone who has it correct and see what I am missing. Then I can understand what I did wrong and fix it for future instances, i.e. : , indent spacing whatever.

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”]) * .1
quizzes = average(student[“quizzes”]) * .3
tests = average(student[“tests”]) * .6
return homework + quizzes + tests

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

students = [“lloyd”,“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)

Above is my code and another thing to not on your code is you don’t even have proper spacing, and that is making think is spacing important. I am not beating you up by no means.I apologize if I am coming off that way I am just trying to get a better understanding. any feed back to why my code doesn’t work would be greatly appreciate. Or even why you did the function get_class_average different would help as well. Thank you for your time.

First time I posted was above, and it didn’t copy my formatting I apologize. For the sake of argument and I don’t want to fill the screen up again. Let’s assume that I have got all the indention correct, and all my formatting is correct. I am strictly talking about how to solve How is Everybody Doing.

Actually @bgilmore1982 is incorrect, Your code gives an error message because you don’t have a variable named students with lloyd alice and tyler as a list right after your last dictionary which is tyler like this,

``````tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}

students = [lloyd, alice, tyler]
``````
4 Likes

As what bandit mention your students list should not be a string of students name as lloyd, alice, and tyler are already a variable.

use students=[lloyd,alice,tyler]

I have tested with the changes and your code works.

I would also like to share and mentioned that the solution I came out with was because I have inadvertently left out exercise 8/9 and hence don’t have the result section.

This just shows that there are many different ways to get the same answer.

Can’t get rid of this error.
Traceback (most recent call last):
File “python”, line 55, in
File “python”, line 53, in get_class_average
File “python”, line 29, in get_average
TypeError: list indices must be integers, not str

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

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

def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])

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"

def get_class_average(students):
results=[]

for student in students:
results.append(get_average(student))
return get_average(results)

print get_class_average(all_students)
``````

Hi trumanjp, I tried running your code, but the variable “all_students” was not defined.

The second thing is
def get_class_average(students):
results=

``````for student in students:
results.append(get_average(student))
return get_average(results)
``````

Instead of get_average(results), it should be average(results).

Your code should work after that. Try it.

Yes this was right. Thank you.

1 Like

Below is the code I’ve been working on. In all honesty I’ve confused myself in part 8 and 9. I’m receiving an error message in my console that says:

Traceback (most recent call last):
File “python”, line 54, in
LookupError: unknown encoding: utf-8

Any help would be greatly appreciated

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]
}

students=[lloyd, alice, tyler]

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

def get_average(student):
homework=average(student[“homework”])*0.1
quizzes=average(student[“quizzes”])*0.3
tests=average(student[“tests”])*0.6

``````return homework + quizzes + tests
``````

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_class_average(students)

Assume that all indentations are in place and that the only addition is the two print statements at the bottom along with the students list.

Hi dappad, I attempted to run your code with all the required indents. It did not give any problems. Perhaps you want to recopy your code with the indents to this forum so that we all can take a look. It could be an issue with the indent.

Haha thanks terajumper57375. Its always when you ask for help that things want to start working properly. Just run the exact same code with no changes to indentation and it went through.

made this code for the last step. I am getting the error
Traceback (most recent call last):
File “python”, line 54, in
File “python”, line 51, in get_class_average
File “python”, line 28, in get_average
TypeError: string indices must be integers, not str.
what am i doing wrong here?

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

def get_average(student):
homework = average(student[“homework”])
quizzes = average(student[“quizzes”])
tests = average(student[“tests”])
taverage = 0.10homework + 0.30quizzes + 0.60*tests
return taverage

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)
students = [“alice”, “lloyd”, “tyler”]
print get_class_average(students)

See @bandit and my reply to @bgilmore1982 above.

students = [“lloyd”, “alice”, “tyler”] should be students = [lloyd, alice, tyler]

Hey terajumper. I seem to have the exact same code as the people who got it resolved but i just cant seem to get it working. So kindly help me with this as i post my entire code below. Thanks.

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]
}

students=[lloyd, alice, tyler]

def average(numbers):
from math import *
total=sum(numbers)
total=float(total)
total=total/len(numbers)

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

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

print result

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

print get_class_average(students)

Hope it shows up with all the indentations as well.

1 Like

Nah indentations dont seem to be showing up. For now kindly just help me with the code.

I keep getting a “One of the following is missing or broken when we tried to use it: alice, lloyd, tyler, students, get_class_average, get_letter_grade” error on my code, I don’t understand 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]
}
students=[“alice”,“lloyd”,“tyler”]

def average(numbers):
total= sum(numbers)
total= float(total)
def get_average(student):
homework=average(student[“homework”])
quizzes=average(student[“quizzes”])
tests=average(student[“tests”])
return (homework0.1)+(quizzes0.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”
def get_class_average(students):
results =
for student in students:
avg = get_average(student)
results.append(avg)
return average(results)
print results
print get_class_average(students)