★filter★lambda 활용하기★[Python 백준 4344 번 평균은 넘겠지]
2023. 3. 28. 15:50
728x90
반응형
VERSION 2.0
import sys
C = int(sys.stdin.readline())
res = []
for p in range(C):
score = list(map(int , sys.stdin.readline().split()))
counts = score[0]
score = score[1:]
avg = (sum(score) / counts)
score = list(filter(lambda x : x>avg ,score))
res.append(round(len(score)/counts *100 , 3))
for i in res:
print("%.3f" %i + "%")
==> list(filter(lambda) ==> 활용하기
VERSION 1.0
import sys
C = int(sys.stdin.readline())
res = []
for i in range(C):
A = list(map(int,sys.stdin.readline().split()))
avg = 0
sum =0
for j in range(1,A[0]+1):
sum+= A[j]
avg = sum/A[0]
a = 0
for p in A[1:]:
if p>avg:
a+=1
res.append(round(a/A[0]*100,3))
for k in res:
print("%.3f" %k + "%")
for문 반복문 체크
728x90
반응형
'Python(백준) > 배열' 카테고리의 다른 글
★reserved()★[Python 백준 10811번 바구니 뒤집기] (0) | 2023.03.27 |
---|---|
★2중 리스트★[Python 백준 10813번 공 바꾸기] (0) | 2023.03.27 |
★FOR문★[Python 백준 10810번 공넣기] (0) | 2023.03.27 |
[Python] 백준 1546번 평균★VER3.0★FOR문 사용하지 않기 (0) | 2023.03.27 |
★VER2.0★max()안쓰고 구하기★[백준 파이썬 2562번 최대] (0) | 2023.03.27 |