Collections.namedtuple()

Sort by

recency

|

1092 Discussions

|

  • + 0 comments
    from collections import namedtuple
    n, cols = int(input()), input().split()
    Student = namedtuple('Student', cols)
    print(f"{sum(int(Student(*input().split()).MARKS) for _ in range(n))/n:.2f}")
    
  • + 0 comments
    from collections import namedtuple
    n, marksheet = int(input()),namedtuple('student', input().split())
    entry = [marksheet(*input().split()) for _ in range(n)]
    print(sum(int(e.MARKS) for e in entry)/n)
    
  • + 0 comments
    from collections import namedtuple
    N = int(input())
    Student = namedtuple('Student', input().split())
    students = [Student(*input().split()) for _ in range(N)]
    marks = sum([int(s.MARKS) for s in students])
    average = marks / N
    print(f"{average:.2f}")
    
  • + 0 comments
    from collections import namedtuple
    n = int(input())
    title = input().split()
    data = namedtuple('data', title)
    res = 0
    for _ in range(n):
        fields = input().split()
        row = data(*fields)
        res += int(row.MARKS)
    print(f"{res/n: .2f}")
    
  • + 0 comments
    from collections import namedtuple
    N, Record = int(input()), namedtuple('Record',input().split())
    print(f"{(sum(int(Record._make(input().split()).MARKS) for _ in range(N)))/N :.2f}")