The library of the weekend is so lively, so many children around to do their homework reminds me of the time I used to read. Just this lesson after the practice is to calculate the average score, think of the teacher if there should be a lot easier to this thing, after all, a count is really enough trouble. It's not a very complicated little script, but it's practical.
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 (LST): #计算平均值, accurate to decimal return float (sum (LST))/len (LST) def get_average (student): #按照不同的比例计算平比分, University Often this way homework = student[' homework '] quiz = student[' quizzes '] test = student[' tests '] return average (Homew ORK) *0.1 +average (Quiz) *0.3 + average (test) *0.6 def get_letter_grade (score): #按照分数排等级 if score >= 90:return "A" Elif score >= and score < 90:return "B" Elif score and SCO Re < 80:retuRN "C" Elif score >= and score < 70:return "D" Else:return "F" def Get_class _average (class_list): #计算全班的平均分, first use the loop to calculate the total score and then remove the total number = 0 for i in Class_list:total + = Get_av
Erage (i) return Total/len (class_list)
Such basic knowledge is firmly followed by the test of logical thinking, the revolution has not been successful, comrades still need to work hard.