9 hows everyone 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!

def average(numbers):
total = sum(numbers)
total = float(total)
return total / len(numbers)
def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
return .1 * homework + .3 * quizzes + .6 * tests
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:
results.append(get_average(student))
return average(results)
students = [lloyd, tyler, alice]
print get_class_average(students)
print get_letter_grade(get_class_average(students))

please help, 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


#2

my new code is
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]
}
students = [lloyd, alice, tyler]
for people in students:
print people["name"]
print people["homework"]
print people["quizzes"]
print people["tests"]

Add your function below!

def average(numbers):
total = sum(numbers)
total = float(total)
return total / len(numbers)
def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
return .1 * homework + .3 * quizzes + .6 * tests
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:
results.append(get_average(student))
return average(results)
print get_class_average
print get_letter_grade(get_class_average(students))
but now the error is
Oops, try again. Did you remember to print the average of the class? It looks like "83.8666666667" wasn't printed.
PLEASE HELP


#4

why dont you write print get_class_average(students)


#5

the same error comes up


#6

Is "83.8666666667" printed?
I cannot see anything wrong with your code.
I cannot send a solution without giving an explanation but I can't find one.
I can only suggest that instead of:

print get_letter_grade(get_class_average(students))

You say something like:

variable = get_class_average(student)
print variable

but technically speaking, isn't that the same thing?


#7

Had the same problem and couldn't find any error either.

I've gotten it to work by using code from another question on the forum. I've compared that to my own afterwards and still couldn't find the problem, maybe it's a bug in the validation as it gave me that error on lesson 9, even if I did not add anything yet!

Anyway, this worked for me:

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) / len(numbers)    
    return total
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    return homework * 0.1 + quizzes * 0.3 + tests * 0.6
def get_letter_grade(score):
    if score >= 90:
        return "A"
    elif score >=80:
        return "B"
    if score >= 70:
        return "C"
    elif score >= 60:
        return "D"
    else:
        return "F"

print get_letter_grade 
print get_letter_grade(lloyd)

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

#8

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