Student Becomes the Teacher part 9


#1


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

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


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)
    avg = total / len(numbers)
    return avg
    
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    tot_avg = 0.10 * homework + 0.30 * quizzes + \
    0.60 * tests
    return tot_avg

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"

get_letter_grade(get_average(lloyd))

def get_class_average(students):
    results = []
    for stu in students:
        avrg = get_average(stu)
        results.append(avrg)
    return average(results)

print get_class_average(s)
print get_letter_grade(print get_class_average(s)


#2

here:

print get_letter_grade(print get_class_average(s)

why two print keywords? One is enough at beginning of the line, also look at your parentheses on this line

finally s is undefined, it should be students, which is a list you build in 3. put it together, which is currently missing. Revisit 3. put it together if you don't remember what was in the list


#3

I see that mistake with print i just copied the above line to input it as argument to the next line. sorry about that.
Also about creating s should it be with quotations or without.
Thanks


#4


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

gives an average value of : 83.66667
gives a grade of B

Still gives an 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

Should say exercise completed


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)
    avg = total / len(numbers)
    return avg
    
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    tot_avg = 0.10 * homework + 0.30 * quizzes + \
    0.60 * tests
    return tot_avg

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"

get_letter_grade(get_average(lloyd))

def get_class_average(students):
    results = []
    for stu in students:
        avrg = get_average(stu)
        results.append(avrg)
    return average(results)

s = [lloyd, alice, tyler]

print get_class_average(s)
print get_letter_grade(get_class_average(s))


#5

the list should be named students, not s


#6

only then it will work ?


#7

yes, the exercise the list is present under that name


#8

Thanks a bunch it worked


#9

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