Make a little progress every day--------Python calculates the average score __python

Source: Internet
Author: User

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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.