How's Everybody doing?


#1



How's everybody doing?


This is the error I am getting
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


print the class average and class letter grade which it does but apparently something is 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]
}

# 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'])
    return 0.1 * homework + 0.3 * quizzes + 0.6 * tests
#print get_average(alice)
#print get_average(lloyd)

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(alice))

def get_class_average(students):
    results = []
    for student in students:
        results.append(get_average(student))
    return average(results)
   
print get_class_average(students = (lloyd,alice,tyler))
print get_letter_grade(get_class_average(students =(lloyd,alice,tyler)))


#3

HI macsidejosh!
When I copy the code you have posted here in to my problem codecadamy passes it!
Are you certain the code in your editor matches what you have here? Perhaps you corrected a typo here and not in your editor. Try deleting the code in your editor and pasting the code you've posted here in its stead.
Hope this helps!
Joe


#4

I don't know why it would be different. I copied and pasted it directly.
I did manage to get past that assignment. I now need to understand why it works it different ways

This message was sent from the MacSide


#5

Hello,

I have the same problem, the code compiles, but I get the message as above from Codeacademy, and it doesn't let me pass the level. How do I proceed?

Thanks for answers, Tomas.


#6

I did this and it passed:

students = [lloyd, alice, tyler]

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

#7

Thanks, wonderful - it works. But, I dont understand, I did this:

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

or this

a = get_class_average([lloyd, alice, tyler])
print a
print get_letter_grade(a)

and it didn't work. Why is this wrong? Does it have to do with the way Codeacademy assess my code? Since I do not see any python-mistakes!!

Yours, Tomas.


#8

Hi,

this is just a test:

print a = get_class

sorry, am learning how to write the question with the code. Tom.

It worked - sorry for inconvenience, fella's.


#9

There don't seem to be any errors in the python code. I think it's a mistake on Codeacademy's part as the error message that pops up when I type in your code is :

'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'.

This suggests it needs you to create a students list in order for you to pass the section.


#10

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