Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9a8f60d

Browse files
Collections.namedtuple()
1 parent 15e9730 commit 9a8f60d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎Hackerrank-Python3/named_tupple.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Collections.namedtuple()
2+
3+
from collections import namedtuple
4+
n = int(input())
5+
fields = input().split()
6+
total = 0
7+
Details = namedtuple('Details', fields)
8+
for i in range(n):
9+
f1, f2, f3, f4 = input().split()
10+
student = Details(f1, f2, f3, f4)
11+
total += int(student.MARKS)
12+
print(total / n)
13+
14+
##### INPUT ####
15+
# 5
16+
# ID MARKS NAME CLASS
17+
# 1 97 Raymond 7
18+
# 2 50 Steven 4
19+
# 3 91 Adrian 9
20+
# 4 72 Stewart 5
21+
# 5 80 Peter 6
22+
#
23+
# ### OUTPUT ###
24+
# 78.00

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /