File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 44Domain : Python
55Author : Ahmedur Rahman Shovon
66Created : 15 July 2016
7+ Updated : 09 February 2023
78Problem : https://www.hackerrank.com/challenges/py-collections-namedtuple/problem
89"""
910
10- n = int (input ())
11- col_list = list (input ().split ())
12- marks_col = col_list .index ("MARKS" )
13- marks_list = []
14- for _ in range (n ):
15- info_list = list (input ().split ())
16- marks_list .append (float (info_list [marks_col ]))
17- print (sum (marks_list ) / n )
11+ from collections import namedtuple
12+ n = int (input ())
13+ columns = "," .join (input ().split ())
14+ Student = namedtuple ("Student" , columns )
15+ data = []
16+ for i in range (n ):
17+ row = input ().split ()
18+ s = Student ._make (row )
19+ data .append (s )
20+ avg = sum (float (s .MARKS ) for s in data ) / n
21+ print (f"{ avg :.2f} " )
You can’t perform that action at this time.
0 commit comments