Collections.namedtuple()

Sort by

recency

|

1101 Discussions

|

  • + 0 comments

    from collections import namedtuple

    n = int(input())

    fields = input().split()

    Student = namedtuple('Student', fields)

    total = 0

    for _ in range(n):

    records = Student(*input().split())
    
    total += float(records.MARKS)
    

    print(f'{total / n:.2f}')

  • + 0 comments

    from collections import namedtuple N, header_line = int(input()), input().split() StudentRecord = namedtuple('StudentRecord', header_line) total_marks = 0 for _ in range(N): data_values = input().split() student=StudentRecord(*data_values)
    total_marks += int(student.MARKS) print(f"{total_marks/N:.2f}")

  • + 0 comments

    from collections import namedtuple N, header_line = int(input()), input().split() StudentRecord = namedtuple('StudentRecord', header_line) total_marks = 0 for _ in range(N): data_values = input().split() student=StudentRecord(*data_values)
    total_marks += int(student.MARKS) print(f"{total_marks/N:.2f}")

  • + 0 comments

    from collections import namedtuple N, header_line = int(input()), input().split() StudentRecord = namedtuple('StudentRecord', header_line) total_marks = 0 for _ in range(N): data_values = input().split() student=StudentRecord(*data_values)
    total_marks += int(student.MARKS) print(f"{total_marks/N:.2f}")

  • + 0 comments

    from collections import namedtuple

    size, fields = int(input()), input().split()

    Student = namedtuple('Student', fields)

    print(f"{sum(int(Student(*input().split()).MARKS) for _ in range(size)) / size}")