티스토리 뷰


[2, 10]범위의 정수 n을 입력받는다.
n줄에 걸쳐 이름과 3과목 점수를 띄어쓰기로 구분해 입력받는다.
누구의 평균점수를 알아 볼것인지 입력받는다.
입력받은 사람의 평균 점수를 소수점 두 자리까지출력한다.
if __name__ == '__main__':
n = int(input())
student_marks = {}
for _ in range(n):
name, *line = input().split()
scores = list(map(float, line))
student_marks[name] = scores
query_name = input()
print(f'{sum(student_marks[query_name])/3:.2f}')

Finding the percentage | HackerRank
Finding the percentage | HackerRank
Store a list of students and marks in a dictionary, and find the average marks obtained by a student.
www.hackerrank.com
'Hackerrank > Python' 카테고리의 다른 글
Nested Lists (0) | 2022.02.06 |
---|---|
Find the Runner-Up Score! (0) | 2022.02.05 |
List Comprehension (0) | 2022.02.05 |
Print Function (0) | 2022.02.05 |
Write a function (0) | 2022.02.05 |