Skip to content

Instantly share code, notes, and snippets.

@evanscottgray
Created August 29, 2014 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanscottgray/21b6ac12303a02dc5a34 to your computer and use it in GitHub Desktop.
Save evanscottgray/21b6ac12303a02dc5a34 to your computer and use it in GitHub Desktop.
codeacademy for towne
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 * .10 + quizzes * .30 + tests * .60
def get_class_average(students):
results = []
for student in students:
avg=get_average(student)
results.append(avg)
return average(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment