[백준] 4344번(format()을 활용한 출력 양식)

·2022년 10월 21일

백준 문제풀이

목록 보기
7/159


최종 제출 코드

num_test = int(input())

for i in range(num_test):
  lists = list(map(int, input().split()))

  nums = lists[0]
  test = lists[1:]
  test_sum = sum(test)
  test_avg = test_sum / nums

  count = 0
  for j in range(nums):
    if test[j] > test_avg:
      count += 1

  print("{:.3f}%".format(count / nums * 100))

📌 주의
sum이나 max를 변수의 이름으로 활용하지 말 것!


"{:.df}".format(변수)

d - 반올림하여 소수점 d번째 자리까지 표시

profile
백엔드 개발자가 되고 싶어요(22.8.15~)

0개의 댓글