티스토리 뷰

Hackerrank/Python

Finding the percentage

.   2022. 2. 6. 04:12

[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
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함