GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — StarterLearningPython/2code/20502p3.py at master · dlimcode/StarterLearningPython

Expand file tree

/

20502p3.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
53 lines (44 loc) · 1.5 KB
/

20502p3.py

Copy path

File metadata and controls

53 lines (44 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# coding=utf-8
"""
统计考试成绩
"""
def average_score(scores):
"""
统计平均分.
"""
score_values = scores.values()
sum_scores = sum(score_values)
average = round(sum_scores/len(score_values), 2) # round(a,2) 保留两位小数
return average
def sorted_score(scores):
"""
对成绩从高到低排队.
"""
score_lst = [(scores[k],k) for k in scores]
sort_lst = sorted(score_lst, reverse=True)
return [(i[1], i[0]) for i in sort_lst]
def max_score(scores):
"""
成绩最高的姓名和分数.
"""
lst = sorted_score(scores) #引用分数排序的函数sorted_score
max_score = lst[0][1]
return [(i[0],i[1]) for i in lst if i[1]==max_score]
def min_score(scores):
"""
成绩最低的姓名和分数.
"""
lst = sorted_score(scores)
min_score = lst[len(lst)-1][1]
return [(i[0],i[1]) for i in lst if i[1]==min_score]
if __name__ == "__main__":
examine_scores = {"google":98, "facebook":99, "baidu":52, "alibaba":80, "yahoo":49, "IBM":70, "android":76, "apple":99, "amazon":99}
ave = average_score(examine_scores)
print("the average score is:{}".format(ave)) #平均分
sor = sorted_score(examine_scores)
print("list of the scores:{}".format(sor)) #成绩表
xueba = max_score(examine_scores)
print("Xueba is:{}".format(xueba)) #学霸们
xuezha = min_score(examine_scores)
print("Xuzha is:{}".format(xuezha)) #学渣们
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.