백준 풀이

[백준/BOJ] - 4344번 python 풀이

반오십 코린이 2022. 11. 18. 12:42
728x90


알게 된 점

1. list.pop(index) <- 를 하면 해당 list의 index 속 값을 return한다. list는 해당 index 값이 사라진다.

2. 반올림하여 소수점 셋째자리까지 출력

f'{val:.3f}'

C = int(input())


cnt = 0

for _ in range(C): 
    s_cnt = 0
    l = list(map(int,input().split()))
    student_num = l.pop(0)
    avr = sum(l)/len(l)
    for i in range(student_num):
        if(l[i] > avr):
            s_cnt +=1
    print(f'{s_cnt/len(l)*100:.3f}%')
728x90