• API
• FAQ
• Tools
• Archive
daily pastebin goal
96%
SHARE
TWEET

# Code Mess

edman270 Mar 19th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. lloyd = {
2.   "name": "Lloyd",
3.   "homework": [90.0, 97.0, 75.0, 92.0],
4.   "quizzes": [88.0, 40.0, 94.0],
5.   "tests": [75.0, 90.0]
6. }
7. alice = {
8.   "name": "Alice",
9.   "homework": [100.0, 92.0, 98.0, 100.0],
10.   "quizzes": [82.0, 83.0, 91.0],
11.   "tests": [89.0, 97.0]
12. }
13. tyler = {
14.   "name": "Tyler",
15.   "homework": [0.0, 87.0, 75.0, 22.0],
16.   "quizzes": [0.0, 75.0, 78.0],
17.   "tests": [100.0, 100.0]
18. }
19.
21. def average(values):
22.     total = float(sum(values))
23.     count = len(values)
25.
26. #returns weighted average for a student
27. def get_average(student):
28.   total = average(student['homework']) * 0.1 + average(student['quizzes']) * 0.3 + average(student['tests']) * .6
30.
31. #returns letter grade from a percentage
34.     if percentage >= 90:
36.     elif percentage >= 80:
38.     elif percentage >= 70: