나를 기록하다
article thumbnail
반응형

1)

# 첫 번째 줄 입력 받기
n = int(input())

# 두 번째 줄 입력 받기
scores = list(map(int, input().split()))

# 세 번째 줄 입력 받기
max_score = max(scores)

# 점수 변환 후 평균 계산
new_scores = [(score/max_score)*100 for score in scores]
new_avg = sum(new_scores)/n

# 새로운 평균 출력
print(new_avg)

주어진 세 줄의 입력을 각각 n, scores, max_score 변수에 저장한 후, 점수 변환 후 평균을 계산하여 new_avg 변수에 저장하고, 마지막으로 new_avg를 출력합니다.

2)

n = int(input())
scores = list(map(int, input().split()))
max_score = max(scores)
new_scores = [score/max_score*100 for score in scores]
print(sum(new_scores)/n)

max() 함수를 사용하여 세준이의 최고점수를 구하고, 리스트 컴프리헨션을 사용하여 모든 점수를 새로운 점수로 변환합니다. 그리고 나서 sum() 함수를 사용하여 모든 점수의 합을 구하고, 이를 시험 본 과목의 개수로 나누어 평균을 구합니다. 이 방법 역시 파이썬에서 많이 사용되는 방법 중 하나입니다.

반응형
profile

나를 기록하다

@prao

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!

profile on loading

Loading...