문제 지문이 길어서 아래 링크로 대신한다.
# 0번 학생의 점수: (0,0), (1,0), (2,0) ... (4,0)
# 1번 학생의 점수: (0,1), (1,1), (2,1) ... (4,1)
# .
# .
# .
# 4번 학생의 점수: (0,4), (1,4), (2,4) ... (4,4)
# n번 학생의 점수: (0,n), (1,n), ... (4,n)
-> x축은 0, 1, 2, 3, 4 가 차례로 온다. -> range(5) -> 일반화하면 range(N)
-> y축은 n으로 고정
student_avg = []
for n in range(N):
n_toal = 0
for m in range(N):
n_total += scores[m][n]
avg = n_total / N
student_avg.append(avg)
student_avg = []
for n in range(len(scores)):
n_toal = 0
for m in range(len(scores)):
n_total += scores[m][n]
avg = n_total / len(scores)
student_avg.append(avg)
만약, 학생들이 자기 자신을 평가한 점수가 유일한 최고점 또는 유일한 최저점이라면 그 점수는 제외하고 평균을 구합니다.
student_avg = []
for n in range(len(scores)):
n_scores = []
for m in range(len(scores)):
n_scores.append(scores[m][n])
if (n_scores[n]==max(n_scores) or n_scores[n]==min(n_scores)) and (n_scores.count(n_scores[n]) == 1):
del n_scores[n]
avg = sum(n_scores) / len(n_scores)
student_avg.append(avg)
else:
avg = sum(n_scores) / len(n_scores)
student_avg.append(avg)
def solution(scores):
answer = ''
student_avg = []
for n in range(len(scores)):
n_scores = []
for m in range(len(scores)):
n_scores.append(scores[m][n])
print(n_scores)
if (n_scores[n]==max(n_scores) or n_scores[n]==min(n_scores)) and (n_scores.count(n_scores[n]) == 1):
del n_scores[n]
avg = sum(n_scores) / len(n_scores)
student_avg.append(avg)
else:
avg = sum(n_scores) / len(n_scores)
student_avg.append(avg)
for avg in student_avg:
if avg >=90:
answer += 'A'
elif avg >=80:
answer += 'B'
elif avg >=70:
answer += 'C'
elif avg >=50:
answer += 'D'
else:
answer += 'F'
return answer