We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
from collections import namedtuple
n=int(input())#number of students
Student=namedtuple('Student',input())#read no.of column headers like ID,MARKS,NAME,CLASS
marks=[]#empty list to collect marks
for i in range(n):
data=input().split()#read student details data=["1","97"]
student=Student(*data)#create student object Student=Student("1","97")
marks.append(int(student.MARKS))#take marks and store it in a list
print(sum(marks)/n)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Collections.namedtuple()
You are viewing a single comment's thread. Return to all comments →
from collections import namedtuple n=int(input())#number of students Student=namedtuple('Student',input())#read no.of column headers like ID,MARKS,NAME,CLASS marks=[]#empty list to collect marks for i in range(n): data=input().split()#read student details data=["1","97"] student=Student(*data)#create student object Student=Student("1","97") marks.append(int(student.MARKS))#take marks and store it in a list print(sum(marks)/n)