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.
as the input for number of students and subjects is given in same line, OP is spliting the input string into list and taking 2nd element of the list to iterate those many times.
Probably very late to ask , i see this post is 4 years ago .but ...
map objects is appended in sheet so in zip(*sheet) the map objects will be unpacked how does zip reaches down to map objects elements ?
columns,row=map(int,input().split())
grades=[]
for _ in range(row):
grades.append(list(map(float,input().split())))
for student in zip(*grades):
print(sum(student)/row)
Zipped!
You are viewing a single comment's thread. Return to all comments →
To keep things clear and simple:
unkempt pubes:
what does the [1] after split() do??
here is solution of problem Zipped in python 2 and python 3 https://solution.programmingoneonone.com/2020/06/hackerrank-zipped-problem-solution-python.html
as the input for number of students and subjects is given in same line, OP is spliting the input string into list and taking 2nd element of the list to iterate those many times.
here is problem solution in python programming. https://programs.programmingoneonone.com/2021/02/hackerrank-zipped-solution-python.html
what does the [1] after split() do??
.split()returns list. [n] returns n-th element of that list.
It's a shortcut of skipping the first input (number of subjects) and going straight for the number of students
Updated solution is here
https://www.thecscience.com/2021/08/hackerrank-Zipped-in-python-problem-solution.html
nyc solution!!!!!!!!!!
Bad practice to use list comprehensions/map for printing items, better use for loop.
readability is highly decreased here.
Excellent! Undertandable to beggeners as well. Like me
Your code exceeds all cases, but i would add format in sake of robustness.
For input cases like:
uuuuuuuuuuuuuu
very nice code............................
What is the use of * symbol here
It's to specify an arbitrary number of arguments. See: https://stackoverflow.com/questions/287085/what-do-args-and-kwargs-mean
from statistics import mean . . . . print(mean(i))
using len(i) is unnecessary and adds more computation per iteration. simply use alreday known value of x
print(sum(i)/ x)
we can use print(sum(i)/X) because len(i) is bit confusing
Almost exactly the same:
Probably very late to ask , i see this post is 4 years ago .but ... map objects is appended in sheet so in zip(*sheet) the map objects will be unpacked how does zip reaches down to map objects elements ?
This solution is more simple and readable
Exact same solution
'*' notation helped me!
what is the meaning of underscore in "for _ in range(x):"
Hi chin999,
it is simple 'for' loop abbreviation in Python. range of x means: # of times for loop to be executed.
why do we put *zip(sheet) and not zip(sheet) what is the difference between this 2? why cant we use the latter?
why does "_" in 'for loop' means?