-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2108.py
More file actions
49 lines (34 loc) · 758 Bytes
/
2108.py
File metadata and controls
49 lines (34 loc) · 758 Bytes
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
# collections counter 사용 count 보다는
import sys
from collections import Counter
item = int(sys.stdin.readline())
lst = []
sum = 0
for i in range(item):
lst.append(int(sys.stdin.readline()))
sum += lst[i]
avg = round(sum/item) # 평균
# 중앙값
lst.sort()
mid = 0
if item % 2 == 1:
mid = lst[item//2]
else:
mid = lst[item//2]+lst[item//2+1]//2
# 범위
r = max(lst)-min(lst)
# 최빈값
def mode(lstlst):
cnt = Counter(lstlst).most_common()
if len(cnt) == 1:
return cnt[0][0]
if cnt[0][1] == cnt[1][1]:
return cnt[1][0]
else:
return cnt[0][0]
mode_num = mode(lst)
# 결과 출력
print(avg)
print(mid)
print(mode_num)
print(r)