File tree 1 file changed +22
-22
lines changed
1 file changed +22
-22
lines changed Original file line number Diff line number Diff line change 7
7
8
8
#解决(python)
9
9
10
- ; #! /usr/bin python
11
- ; #coding: utf-8
12
- ;
13
- ;
14
- ; from __ future__ import division #实现精确的除法,例如4/3=1.333333
15
- ; import random
16
- ;
17
- ; def make_score(num):
18
- ; score = [ random.randint(0,100) for i in range(num)]
19
- ; return score
20
- ;
21
- ; def less_average(score):
22
- ; num = len(score)
23
- ; sum_score = sum(score)
24
- ; ave_num = sum_score/num
25
- ; less_ave = [ i for i in score if i<ave_num]
26
- ; return len(less_ave)
27
- ;
28
- ; if __ name__ =="__ main__ ":
29
- ; score = make_score(40)
30
- ; print "the number of less average is:",less_average(score)
31
- ; print "the every socre is[ from big to small] :",sorted(score,reverse=True)
10
+ #! /usr/bin python
11
+ #coding:utf-8
12
+
13
+
14
+ from __future__ import division #实现精确的除法,例如4/3=1.333333
15
+ import random
16
+
17
+ def make_score(num):
18
+ score = [random.randint(0,100) for i in range(num)]
19
+ return score
20
+
21
+ def less_average(score):
22
+ num = len(score)
23
+ sum_score = sum(score)
24
+ ave_num = sum_score/num
25
+ less_ave = [i for i in score if i<ave_num]
26
+ return len(less_ave)
27
+
28
+ if __name__=="__main__":
29
+ score = make_score(40)
30
+ print "the number of less average is:",less_average(score)
31
+ print "the every socre is[from big to small]:",sorted(score,reverse=True)
You can’t perform that action at this time.
0 commit comments