9. How is Everybody Doing?


#1

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!
students=[lloyd,alice,tyler]
def average (numbers):
    total=sum(numbers)
    l=len(numbers)
    total=float(total)
    result=total/l
    return result

def get_average (student):
    homework=average(student["homework"])
    quizzes=average(student["quizzes"])
    tests=average(student ["tests"])
    return 0.10*homework+0.30*quizzes+0.60*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_class_average(students)
print get_letter_grade(get_class_average(students))

what is wrong in the above code its giving error

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

Please Help


#2

students = [lloyd , alice , tyler]
print (get_class_average(students))


#3

just follow up @pry2015 said
and this is my problem solved
student = [lloyd, alice, tyler]
print get_class_average(student)
print get_letter_grade(83)

*83 is the average class then i input it to the "get_letter_grade()"


#4

i have exactly the same problem but i don't understand how we solve this problem, can you explain me?


#5

this is not solved please show your code
@ahmad_m


#7

Heyho,

yout code should work when you call the functions like below:

students = [lloyd, alice, tyler]

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


#8
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)
    total = total / len(numbers)
    return total
def get_average(student):
    lloyd_homework=average(student['homework'])
    lloyd_quizzes=average(student['quizzes'])
    lloyd_tests=average(student['tests'])
    lloyd_average_score=0.1*lloyd_homework+0.3*lloyd_quizzes\
    +0.6*lloyd_tests
    return lloyd_average_score
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_average(lloyd)
def get_class_average(students=[lloyd, alice, tyler]):
    results=[]
    for student in students:
        ga=get_average(student)

        results.append(ga)

    return average(results)
           students = [lloyd, alice, tyler]
           print get_class_average(students)
           print get_letter_grade(get_class_average(students))

i am getting the error is
** One of the following is missing or broken when we tried to use it: alice, lloyd, tyler, students, get_class_average, get_letter_grade**

Please Guide Me Thanks in Advance


#10

it doesn't...................


#11

try this for last line nothing else worked for me

print get_letter_grade(round(get_class_average(students)))


#12

thanks bro its work i have following code

average = get_class_average(students)
print average
print get_letter_grade(average)

Answer is showing correct but it is not letting me pass the exercise.


#13

This worked for me(but indent properly)!!

# Add your function below!
def average(numbers):
    total=float(sum(numbers))
    average=total/len(numbers)
    return average
def get_average(student):
    homework=average(student["homework"])
    quizzes=average(student["quizzes"])
    tests=average(student["tests"])
    sum = 0.10*homework+0.30*quizzes+0.60*tests
    return sum
def get_letter_grade(score):
    if score>=90:
        return "A"
    elif score>=80 and score<90:
        return "B"
    elif score>=70 and score<80:
        return "C"
    elif score>=60 and score<70:
        return "D"
    else:
        return "F"
def get_class_average(students):
    results=[]
    for student in students:
        result=get_average(student)
        results.append(result)
    return average(results)   
students = [lloyd, alice, tyler]
print get_class_average(students)
print get_letter_grade(get_class_average(students))

#14

Hi @advaitpundlik, Your code seems to be working on this exercise, please re-check if it still produces any errors.

Thanks!


#15

this worked for me...check out!

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!
students=[lloyd,alice,tyler]
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"])
    homework=float(homework)
    quizzes=float(quizzes)
    tests=float(tests)
    grade=0.1*homework+0.3*quizzes+0.6*tests
    return grade
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_class_average(students)
print get_letter_grade(get_class_average(students))

#16

still not working @gaurangtandon


#17

finally worked THANK YOU ..@gaurangtandon


#19

3 posts were merged into an existing topic: How Everybody Doing: Error


#20

It does work its the second line that got me confused


#21

This is really a ■■■■■■■■ exercise. The answer was what i was getting as an error message with a slightly different variation of code. Codecademy's Python lessons are not well put together, described, or supported as you move to the higher lessons. This code worked though


#22

well as far as i can see you must print the average and the send it to the the function get letter grade so it can return a letter


#23

If you pass get_letter_grade the static value '83', then what happens when the student's scores change or they start the next year of class? Are they guaranteed a 'B' in perpetuity because of software error?

You can call a function within a function to solve this problem.
students=[lloyd, alice, tyler]

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