How's everybody doing?


#1

I need help with my code this is my code what am I doing wrong?? :persevere:

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)
total = float(total)
average = total / len(numbers)
return average
def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
weighted = (homework*.1)+(quizzes*.3)+(tests*.6)
return weighted
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(lloyd)
def average(numbers):

    total = sum(numbers)

    average = float(total) / len(numbers)
    return average

print get_class_average[lloyd, alice, tyler]
print get_letter_grade

Help is greatly apprecieted :blush:


#2

Please post a link to the this exercise, as well as the error messages. Thanks.


#3

I'm confused :confused:


#4

What do you mean?? :disappointed:


#5

Copy the address from the location bar and paste it into a reply. Copy the error message(s) from the the editor and or the console and paste them into the reply.


#6

The Problem Can you help


#7

A
Traceback (most recent call last):
File "python", line 51, in
NameError: name 'get_class_average' is not defined

That's what it says


#8

You don't have a get_class-average function, but you do have average twice. You'll need to go through your code an make sure all the functions are there.

Declare a students list just under the data dictionaries.

students = [lloyd, alice, tyler]

When you have the function written, be sure to call it like,

print get_class_average(students)

#9

I still don't get what you mean :confused:


9. How is Everybody Doing?
9. How is Everybody Doing?
#10

The functions we should have for this exercise, are,

average              takes a list of numbers
get_average          takes a student dictionary
get_letter_grade     takes a single grade (number)
get_class_average    takes a list of student identifiers

Organize your code and please make an effort to format it when posting into the forums.


#12

Ok I think I get it now thank you


#13

Here's my new code what am I doing wrong??


#14

The data section is,

lloyd = {}
alice = {}
tyler = {}

students = [lloyd, alice, tyler]

The class list (students) (as it is referred to in the lesson) is the list of identifiers that we pass to the last function.


#15

It doesn't work for me is that a soulution??


#16

No. Just a schematic. Suggest go back to the beginning and start over. Make sure each function works as expected before going to the next lesson.


#17

2 posts were split to a new topic: I don't get it


#18

4 posts were split to a new topic: Give me a clue about what is wrong here


#22

2 posts were split to a new topic: What is wrong with this code


#23

A post was merged into an existing topic: What is wrong with this code


#24