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.
Collections.namedtuple()
Collections.namedtuple()
Sort by
recency
|
1069 Discussions
|
Please Login in order to post a comment
from collections import namedtuple N = int(input()) Student = namedtuple('Student', input().split()) students = [ Student(*(input().split()) ) for row in range(N) ] print( sum([ int(s.MARKS) for s in students ]) / len(students) )
from collections import namedtuple
num, Student = int(input()), namedtuple("Student", input() ) print(f"{sum([int(Student(*input().split()).MARKS) for _ in range(num)])/num:.2f}") 1 line of code is enough
n, order = int(input()), input().split();print(f"{sum([int(dict(zip(order, input().split())).get("MARKS")) for i in range(n)])/n:.2f}")
One line of code
N=int(input()) from collections import namedtuple Sm=namedtuple('Sm',f"{input()}") i=[int(Sm(*input().split()).MARKS)for _ in range(N)] print(f'{sum(i)/N : .2f}')