본문 바로가기

Python/BOJ

[Python] 백준 1546: 평균

https://www.acmicpc.net/problem/1546

 

1546번: 평균

첫째 줄에 시험 본 과목의 개수 N이 주어진다. 이 값은 1000보다 작거나 같다. 둘째 줄에 세준이의 현재 성적이 주어진다. 이 값은 100보다 작거나 같은 음이 아닌 정수이고, 적어도 하나의 값은 0보

www.acmicpc.net

n = int(input())
list = list(map(int,input().split()))
max = max(list)

new_list = []
for i in list:
    new_list.append(i/max*100)
avg = sum(new_list)/n
print(avg)

코드 해석


  • 가장 높은 점수를 찾기
n = int(input())
list = list(map(int,input().split()))
max = max(list)
  • 이후 주어진 조건에 맞게 새로운 값들을 계산
new_list = []
for i in list:
    new_list.append(i/max*100)
avg = sum(new_list)/n

 

'Python > BOJ' 카테고리의 다른 글

[Python] 백준 8958: OX퀴즈  (0) 2021.09.11
[Python] 백준 3052: 나머지  (0) 2021.09.10
[Python] 백준 2577: 숫자의 개수  (0) 2021.09.10
[Python] 백준 10818 최소, 최대  (0) 2021.08.22
[Python] 백준 1110 더하기 사이클  (0) 2021.08.21