# Lesson 9 How everybody doing. This is the only lesson left to complete the Python course.Can some one help pl

#1

My code is given below.

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)

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

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)
students = [alice,tyler]
print get_class_average(students)

#2

You are missing lloyd in the students list. Also, format your code properly.

#3

The revised code is as below.The error says the average 83.86------- was not printed.Pl suggest the modifification

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]

def average(numbers):
total = float(sum(numbers))
result = total / float(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

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

#4

I see that you got rid of the students list, that is correct, but you also ruined a correct part of your code!

Last two lines are an abomination! You are printing functions without arguments(?!)

Instructions say:
Finally, print out the result of calling get_class_average with your students list
Then, print the result of get_letter_grade for the class's average

So, instead of "print get_class_average" you should type "print get_class_average(students)"
And instead of "print get_grade_letter"(which is not even a vaid function name, since the function is get_letter_grade()) you should type "print get_letter_grade(get_class_average(students))"

Maybe you should revise a bit, but I get you, those exercises aren't your code(it's not something you thought yourself, but something the tutor thought) and it's easy to get lost in all these lines of code, it happens to me all the time

#5

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