GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — StarterLearningPython/2code/20502.py at master · solidblack/StarterLearningPython Expand file tree/ Copy path20502.pyMore file actions 55 lines (45 loc) · 1.35 KB / Copy path20502.pyFile metadata and controls55 lines (45 loc) · 1.35 KB 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 54 #!/usr/bin/env python # coding=utf-8 """ count the examine scores """ from __future__ import division def average_score(scores): """ count average score. """ score_values = scores.values() sum_scores = sum(score_values) average = sum_scores/len(score_values) return average def sorted_score(scores): """ count the list for max to min. """ 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): """ the max scroe and the person's name. """ lst = sorted_score(scores) max_score = lst[0][1] return [(i[0],i[1]) for i in lst if i[1]==max_score] def min_score(scores): """ the min score and the person's name. """ 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: ",ave sor = sorted_score(examine_scores) print "list of the scores: ",sor xueba = max_score(examine_scores) print "Xueba is: ",xueba xuezha = min_score(examine_scores) print "Xuzha is: ",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. |