Part of the whole


#1

vaishnavi.tamanekar:


#2

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

#3

Thanks for helping,I corrected the return statement,but they are still showing some fault which I cannot figure out.......


#4

Hi @vaishnavi.tamanekar ,

I see nothing wrong with your code. That being said, you should stick to CodeCademy instructions as the console has restrictions as to what it should consider correct.

I had some lessons where I tried to be a wise ■■■ and I just ended up getting errors believing my code was incorrect when it was just some code not expected by CodeCademy console.

You should loop through your students class and then append the results variable without creating any new variable (in your case, you created a variable called x).


#5

https://www.codecademy.com/courses/python-beginner-en-qzsCL/1/5?curriculum_id=4f89dab3d788890003000096

hi @netrunner10450 ,
I tried doing what you recommended ,but i am still getting an error :frowning:
I have attached the link.
Thank you .


#6

Hi @vaishnavi.tamanekar ,

When I click through your link, I get my version of the code.

Can you copy your code and paste it here ? Or you can do another screen cap, I don't mind.
If you use a screen cap, please make sure the error message you're getting appears.


#7

Hello @netrunner10450,
Here is the screeshot of the error that shows up after making the changes.


#8

@vaishnavi.tamanekar

Ok, now I get the error message but not the whole code.

Basically, what the error says that before even inspecting your code, one key function or variable has a typo.
It gave you a list :

alice # lloyd # tyler # students # get_class_average # get_letter_grade

So, you need to go through each time one of these words is mentioned in your code and pay a close attention to how they're spelled.

Then, if still you get this message, we have to see the code.
You need to type it. It's easy to do so :

  1. You copy your code
  2. You paste it as a reply
  3. You highlight it
  4. You click on the < / > button right in the toolbar.

#9

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