#information for three studentsLloyd = { "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!#find the average of a listdefaverage (number): Total=sum (number) Total=float (total)returntotal/len (number)#to ask for a weighted average of all grades of a studentdefget_average (Student): Homework=average (student["Homework"]) Quizzes=average (student["Quizzes"]) tests=average (student["tests"]) returnhomework*0.1+quizzes*0.3+tests*0.6#graded according to fractionsdefGet_letter_grade (score):ifScore>=90: return 'A' elifScore>=80: return 'B' elifScore>=70: return 'C' elifScore>=60: return 'D' Else: return 'F'#get Lloyd's rankGet_letter_grade (Get_average (Lloyd))#count all students ' scores in a new list and averagedefGet_class_average (Students): Results=[] forStudentinchStudents:results.append (Get_average (student))returnaverage (results)#Student Informationstudents=[Lloyd,alice,tyler]#Print class total average score and gradePrintget_class_average (students)PrintGet_letter_grade (Get_class_average (students))
Python Codecademy Student becomes the Teacher