9/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!

def average(numbers):
total = 0
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(student):
if type(student) == dict :
if get_average(student) >= 90:
grade = "A"
elif get_average(student) >= 80:
grade = "B"
elif get_average(student) >= 70:
grade = "C"
elif get_average(student) >= 60:
grade = "D"
else:
grade = "F"
return grade

elif type(student) == float or type(student) == int:
if student >= 90:
grade = "A"
elif student >= 80:
grade = "B"
elif student >= 70:
grade = "C"
elif student >= 60:
grade = "D"
else:
grade = "F"
return grade

class_list = [lloyd, alice, tyler]

def get_class_average(class_list):
results = []
for student in class_list:
stu_avg = get_average(student)
results.append(stu_avg)

return average(results)

numeric_total = (get_class_average(class_list))
print get_class_average(class_list)
print get_letter_grade(get_class_average(class_list))

**Can i done this like that? I’m seriously overclocking my brain lol **
It gives an error, but the results are correct. It’s because the name’s function i used? And the def get_letter_grade(student) it’s a little bit different. It’s why ??

Thanks a lot


#2

Taking liberties with lessons will have consequences. Follow the instructions to the letter for best results. What you do on your own for experimentation and extended learning is not meant to be done in the course framework. The SCT is not very broad in focus and can only accept what is expected.


#3

When asking about an error on the discussion forums, it is always a good practice to report the contents of the error message.


#4

Thanks a lot for your answer. It help solve my problem, and i understand now.
Yes, probably i should maintain between the exercise guidelines. It should solve future doubts.


#5

Sure, i’ll keep it in mind for next post.
Thank you for your answer.


#6

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