Collections.namedtuple()

Sort by

recency

|

1080 Discussions

|

  • + 0 comments

    Here is HackerRank Collections.namedtuples() in python solution - https://programmingoneonone.com/hackerrank-collections-namedtuple-solution-in-python.html

  • + 0 comments
    total = int(input())
    colums = input().split()
    info_ = list(input().split() for i in range(total))
    print(sum(list(map(int, list(map(lambda x: x[colums.index("MARKS")], info_)))))/total)
    

  • + 0 comments

    Collections.namedtuple() is a factory function in Python provided by the collections module that allows you to create simple, immutable classes for storing data — similar to a lightweight class, but with less boilerplate. Gold 365 Site

  • + 0 comments

    You can actually forget about namedtuple and just do it old-fashined way ;) Could be shorter ~>_<~

    count, marksIndex = int(input()), input().split().index("MARKS")
    print(sum([int(input().split()[marksIndex]) for a in range(count)])/count)  
    
  • + 0 comments
    from collections import namedtuple
    N, Student = int(input()), namedtuple('Student', input().split())
    print(sum([int(Student(*input().split()).MARKS) for _ in range(N)])/N)