Python Codecademy Student becomes the Teacher

Source: Internet
Author: User

#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

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.