zip([iterable, ...])

This function returns a list of tuples. The $i^{th}$ tuple contains the $i^{th}$ element from each of the argument sequences or iterables. 

If the argument sequences are of unequal lengths, then the returned list is truncated to the length of the shortest argument sequence. 

Sample Code

>>> print zip([1,2,3,4,5,6],'Hacker')
[(1, 'H'), (2, 'a'), (3, 'c'), (4, 'k'), (5, 'e'), (6, 'r')]
>>> 
>>> print zip([1,2,3,4,5,6],[0,9,8,7,6,5,4,3,2,1])
[(1, 0), (2, 9), (3, 8), (4, 7), (5, 6), (6, 5)]
>>> 
>>> A = [1,2,3]
>>> B = [6,5,4]
>>> C = [7,8,9]
>>> X = [A] + [B] + [C]
>>> 
>>> print zip(*X)
[(1, 6, 7), (2, 5, 8), (3, 4, 9)]

Task

The National University conducts an examination of $N$ students in $\mbox{X}$ subjects. 

Your task is to compute the average scores of each student.

$\textit{Average score}=\frac{\textit{Sum of scores obtained in all subjects by a student}}{\textit{Total number of subjects}}$

The format for the general mark sheet is:

Student ID → ___1_____2_____3_____4_____5__               
Subject 1   |  89    90    78    93    80
Subject 2   |  90    91    85    88    86  
Subject 3   |  91    92    83    89    90.5
            |______________________________
Average        90    91    82    90    85.5 

Input Format

The first line contains $N$ and $\mbox{X}$ separated by a space. 

The next $\mbox{X}$ lines contains the space separated marks obtained by students in a particular subject. 

Constraints

$0<N\leq100$ 

$0<X\leq100$

Output Format

Print the averages of all students on separate lines.

The averages must be correct up to $\mbox{1}$ decimal place.

Sample Input
5 3
89 90 78 93 80
90 91 85 88 86  
91 92 83 89 90.5

Sample Output
90.0 
91.0 
82.0 
90.0 
85.5        

Explanation

Marks obtained by student 1:  $89,90,91$ 

 Average marks of student 1: 

 $270/3=90$

Marks obtained by student 2: $90,91,92$ 

 Average marks of student 2: 

 $273/3=91$

Marks obtained by student 3: $78,85,83$ 

 Average marks of student 3: 

 $246/3=82$

Marks obtained by student 4: $93,88,89$ 

 Average marks of student 4: 

 $270/3=90$

Marks obtained by student 5: $80,86,90.5$ 

 Average marks of student 5: 

 $256.5/3=85.5$

Source: hackerrank | Difficulty: EASY


Solutions:
a = list(map(int, input().split()))
l = []
fin = []
for i in range(a[1]):
	l.append(map(float, input().split()))
for i in map(lambda x: x / a[1], map(sum, zip(*l))):
	print(i)


from functools import reduce
(nStu, nSub) = map(int, input().split())
sub = []
for i in range(0, nSub):
	sub.append(list(map(float, input().split())))
for i in range(0, nStu):
	stuMarks = [x[i] for x in sub]
	su = reduce(lambda x, y: x + y, stuMarks)
	print(su / nSub)


(n, x) = map(int, input().strip().split())
r = [map(float, input().strip().split()) for _ in range(x)]
for numbers in zip(*r):
	print(sum(numbers) / len(numbers))


(N, X) = map(int, input().strip().split())
from collections import defaultdict
data = defaultdict()
for i in range(X):
	data[i] = list(map(float, input().strip().split()))
	if i == 0:
		lala = [data[i]]
	else:
		lala = lala + [data[i]]

def aver(num):
	return sum(num) / X
for k in list(map(aver, zip(*lala))):
	print(k)


(sub, stu) = input().split()
student = []
temp = []
for i in range(int(stu)):
	for j in input().split():
		temp.append(float(j))
	student.append(temp)
	temp = []
d = zip(*student)
fin = [list(a) for a in zip(*student)]
res = []
for i in fin:
	res.append(sum(i) / int(stu))
for j in res:
	print(j)


a = []
(N, P) = (int(i) for i in input().split())
for i in range(P):
	a.append(list((float(i) for i in input().split())))
for i in zip(*a):
	print(sum(i) / P)


N = int(input().split()[1])
for i in map(lambda x: sum(x) / len(x), zip(*map(lambda x: map(lambda y: float(y), input().split()), range(N)))):
	print(i)


(N, X) = map(int, input().split())
print('\n'.join(map(str, list((sum(t) / len(t) for t in list(zip(*list((list(map(float, input().split())) for _ in range(X))))))))))


(length, line) = [int(x) for x in input().split()]
lines = []
for i in range(0, line):
	lines.append([float(x) for x in input().split()])
a = zip(*lines)
for x in a:
	print(sum(x) / line)


(a, b) = map(int, input().split())
l = []
for i in range(b):
	ss = list(map(float, input().split()))
	l.append(ss)
x = []
for i in l:
	x = x + [i]
x = zip(*x)
for i in x:
	print(sum(i) / b)


(a, b) = input().split()
c = [list(map(float, input().split())) for i in range(int(b))]
print('\n'.join(map(str, [round(sum(i) / int(b), 1) for i in zip(*c)])))


(n, x) = tuple(map(int, input().split()))
l = [list(map(float, input().split())) for _ in range(x)]
for i in range(n):
	sum = 0
	for j in l:
		sum += j[i]
	print(sum / x)


(N, X) = map(int, input().split())
A = []
for _ in range(X):
	A.append(list(map(float, input().split())))
for i in range(N):
	total = 0
	for j in range(X):
		total += A[j][i]
	print('{0:.1f}'.format(total / X))


(l, n) = map(int, input().split())
arr = []
for i in range(0, n):
	arr.append(map(float, input().split()))
Z = zip(*arr)
for i in Z:
	print(sum(i) / n)


import operator

def read_f(f):
	return f(input())

def read_f_words(f):
	return map(f, input().split())
(n, x) = read_f_words(int)
for i in range(x):
	si = read_f_words(float)
	if i == 0:
		s = si
	else:
		s = map(operator.add, s, si)
s2 = list(map(lambda si: si / float(x), s))
for i in range(len(s2)):
	print(s2[i])


(students, marks) = [int(x) for x in input().split()]
all_mark = []
for _ in range(marks):
	all_mark.append([float(x) for x in input().split()])
for mark in zip(*all_mark):
	print(sum(mark) / marks)


a = list(map(int, list(input().split())))[1]
c = []
for i in range(a):
	c.append(list(map(float, list(input().split()))))
for i in list(zip(*c)):
	print(sum(i) / len(i))


(n, m) = list(map(int, input().strip().split()))
s = [input().strip().split() for _ in range(m)]
for j in range(n):
	print(sum([float(s[i][j]) for i in range(m)]) / float(m))


(s, n) = list(map(int, input().split()))
ns = []
for i in range(n):
	ns.append(list(map(float, input().split())))
ns = zip(*ns)
print('\n'.join((str(sum(x) / len(x)) for x in ns)))


(N, X) = map(int, input().split())
score = []
for _ in range(X):
	score.append(list(map(float, input().split())))
for stud in list(zip(*score)):
	print('%.1f' % (sum(stud) / len(stud)))


(n, x) = map(int, input().split())
for i in zip(*[map(float, input().split()) for _ in range(x)]):
	print(round(sum(i) / len(i), 1))


(n, x) = input().split()
marks = []
for _ in range(int(x)):
	marks.append(map(float, input().split()))
print('\n'.join([str(sum(x) / len(x)) for x in zip(*marks)]))


(n, x) = map(int, str(input()).strip().split())
grades = []
for i in range(x):
	grades += [list(map(float, str(input()).strip().split(' ', n)))]
for student in zip(*grades):
	print(sum(student) / x)


(n, x) = map(int, input().split())
marks = []
for i in range(x):
	marks.append(map(float, input().split()))
for t in zip(*marks):
	print('{:.1f}'.format(sum(t) / len(t)))


(stu, sub) = map(int, input().split())
arr = []
for s in range(sub):
	arr.append(list(map(float, input().split())))
z = zip(*arr)
for s in z:
	print(sum(s) / sub)


(n, m) = map(int, input().split())
f = list()
for i in range(m):
	a = list(map(float, input().split()))
	f += [a]
fz = zip(*f)
for item in fz:
	print(sum((i for i in item)) / m)


(numofstu, testcase) = map(int, input().split())
marks = list()
for i in range(testcase):
	marks.append(list(map(eval, input().split())))
SumOfMrks = zip(*marks)
Sum = [sum(a) / testcase for a in SumOfMrks]
for i in Sum:
	print(i)


(n, m) = map(int, input().split())
X = []
for i in range(m):
	X.append([float(x) for x in input().split()])
res = list(zip(*X))
for x in res:
	print('%.1f' % (sum(x) / m))


(n, x) = tuple([int(x) for x in input().split()])
marks = []
for _ in range(x):
	marks.append([float(x) for x in input().split()])
for student_marks in zip(*marks):
	print(sum(student_marks) / float(len(student_marks)))


(N, X) = map(int, input().split())
results = []
for i in range(X):
	results.append(list(map(float, input().split())))
results = list(zip(*results))
for i in range(N):
	print(sum(results[i]) / X)


import statistics
(n, x) = map(int, input().split())
marks = []
for _ in range(x):
	marks.append(list(map(float, input().split())))
for vals in zip(*marks):
	print('%.1f' % statistics.mean(vals))


notes = []
(N, X) = [int(n) for n in input().split()]
for i in range(X):
	notes.append([float(n) for n in input().split()])
notes = list(zip(*notes))
for student in notes:
	final = 0
	for note in student:
		final += note
	final = final / X
	print(final)


from statistics import mean
(n, x) = input().split()
n = int(n)
x = int(x)
marks = []
for _ in range(x):
	marks.append([float(x) for x in input().split()])
for x in zip(*marks):
	print(mean(x))


(n, m) = input().split()
a = []
x = []
for i in range(int(m)):
	a.append(input().split())
for i in list(zip(*a)):
	su = 0
	for k in i:
		su = su + float(k)
	x.append(su)
for k in range(len(x)):
	print(x[k] / int(m))


def __starting_point():
	(st_num, sb_num) = list(map(int, input().strip().split()))
	scores = []
	for _ in range(sb_num):
		scores.append(list(map(float, input().strip().split())))
	for el in zip(*scores):
		print(sum(el) / sb_num)
__starting_point()


S = list()
for _ in range(list(map(int, input().split()))[1]):
	S.append(list(map(float, input().split())))
for i in zip(*S):
	print(sum(i) / float(len(i)))


(N, X) = map(int, input().split())
marks = []
for x in range(X):
	marks.append(list(map(float, input().split())))
students = list(zip(*marks))
for student in students:
	print(sum(student) / X)


(n, x) = map(int, input().split())
scores = []
for i in range(x):
	scores.append(list(map(float, input().split())))
y = zip(*scores)
for j in y:
	print(round(sum(j) / x, 1))


(scores, tests) = map(int, input().split())
data = []
for x in range(tests):
	tmp = list(map(float, input().split()))
	data.append(tmp)
data = list(zip(*data))
for each in data:
	print(sum(each) / tests)


(n, m) = map(int, input().split())
grades = []
for i in range(m):
	grades.append(map(float, input().split()))
students = zip(*grades)
for student in students:
	print(sum(student) / m)


def get_average(students_amt, lines):
	student_nums = list(range(students_amt))
	stu_sums = [0] * students_amt
	tuples = []
	for line in lines:
		tuples.extend(zip(student_nums, line))
	for tup in tuples:
		idx = tup[0]
		stu_sums[idx] += float(tup[1])
	return [i / len(lines) for i in stu_sums]
(student_amt, tests_amt) = input().split()
lines = []
for j in range(int(tests_amt)):
	scores = input()
	line = [float(score) for score in scores.split()]
	lines.append(line)
avgs = get_average(int(student_amt), lines)
for avg in avgs:
	print(str(avg))


nums = lambda f: map(f, input().split())
(_, x) = nums(int)
z = zip(*list((nums(float) for _ in range(x))))
for s in z:
	print('{:.1f}'.format(sum(s) / x))


(N, X) = list(map(int, input().split()))
lis = []
for i in range(0, X):
	lis.append([float(x) for x in input().split()])
for i in zip(*lis):
	print('%.1f' % (sum(i) / X))


(sc, st) = input().split()
data = []
for i in range(int(st)):
	data.append(list(map(float, input().split())))
for k in zip(*data):
	print(sum(k) / len(k))


s = input()
(n, m) = map(int, s.split(' '))
aOfa = []
for i in range(0, m):
	tempArray = input().rstrip().split(' ')
	tempArray = map(float, tempArray)
	aOfa.append(tempArray)
tuples = list(zip(*aOfa))
for v in tuples:
	s = sum(v)
	size = len(v)
	print(float(s / size))


from statistics import mean
(n, x) = map(int, input().split())
mks = []
for i in range(x):
	ms = map(float, input().split())
	mks.append(list(ms))
tot = list(zip(*mks))
for i in range(len(tot)):
	print(mean(list(tot[i])))


(n, m) = map(int, input().split())
l = []
for i in range(m):
	l.append(list(map(float, input().split())))
for x in zip(*l):
	print(sum(x) / m)


(N, X) = map(int, input().split())
for i in map(lambda t: sum(t) / len(t), zip(*[map(float, input().split()) for i in range(X)])):
	print(i)


(n, m) = map(int, input().split())
lol = []
for _ in range(m):
	lol.append(list(map(float, input().split())))
lol = zip(*lol)
for i in lol:
	print(sum(i) / m)


(N, X) = map(int, input().split())
l = []
for i in range(X):
	l.append(map(float, input().split(' ')))
for el in zip(*l):
	print(sum(el) / X)


(n, x) = map(int, input().split())
rows = []
for i in range(x):
	rows.append(map(float, input().split()))
gradesCombined = zip(*rows)
for gradesCombinedCurr in gradesCombined:
	print(sum(gradesCombinedCurr) / len(gradesCombinedCurr))


import itertools
(n, x) = input().split()
n = int(n)
x = int(x)
a = list(input().split())
a = list(map(float, a))
b = []
sums = ['' for x in range(0, n)]
for i in range(0, x - 1):
	b = list(input().split())
	b = list(map(float, b))
	a = a + b
	zipped = zip(a, b)
	tuples = list(zipped)
	for L in range(0, len(tuples)):
		sums[L] = tuples[L][0] + tuples[L][1]
	a = sums
for i in range(0, n):
	print(sums[i] / x)


(N, X) = map(int, input().split())
score = []
for i in range(X):
	score.append(list(map(float, input().split())))
for i in list(zip(*score)):
	print('%.1f' % (sum(i) / len(i)))


(N, X) = map(int, input().split())
L = []
M = []
for i in range(X):
	L = list(map(float, input().split()))
	M.append(L)
L = list(map(list, zip(*M)))
M = list(map(sum, L))
for i in M:
	print(i / X)


import decimal
with decimal.localcontext() as ctx:
	ctx.prec = 1
line = list(map(int, input().split()))
n = line[0]
x = line[1]
arr = []
for i in range(0, x):
	arr.append(list(map(float, input().split())))
za = zip(*arr)
for t in za:
	print(decimal.Decimal(sum(t) / x))


nx = input().split()
n = int(nx[0])
x = int(nx[1])
tbl = []
for i in range(0, x):
	scores = list(map(float, input().split()))
	tbl.append(scores)
for e in zip(*tbl):
	print(sum(list(e)) / x)


(a, b) = map(int, input().split())
L = []
for i in range(b):
	L.append(list(map(float, input().split())))
L = list(zip(*L))
for item in L:
	print(sum(item) / b)


(n, x) = tuple(map(int, input().split()))
marks = []
for i in range(x):
	marks.append(list(map(float, input().split())))
for t in list(zip(*marks)):
	print(sum(t) / x)


(n, s) = map(int, input().split())
sl = []
for i in range(s):
	sl.append(list(map(float, input().split())))
z = zip(*sl)
for item in z:
	print('%.1f' % (sum(item) / s))


(n, x) = map(int, input().split())
arr = []
for i in range(x):
	arr.append([float(i) for i in input().split()])
for i in list(zip(*arr)):
	print(sum(i) / len(i))


(N, X) = map(int, input().split())
stud = []
for i in range(X):
	stud.append(list(map(float, input().split())))
for i in zip(*stud):
	print(sum(i) / X)


(n, x) = map(int, input().split())
subjects_scores = []
for _ in range(x):
	subjects_scores.append(map(float, input().split()))
students_scores = zip(*subjects_scores)
for scores in students_scores:
	print('%.1f' % (sum(scores) / len(scores)))


(s, g) = map(int, input().split())
a = []
for i in range(g):
	a.append(list(map(float, input().split())))
list(map(lambda x: print(sum(x) / g), zip(*a)))


(nb, x) = map(int, input().split())
ls = [[0]] * x
for i in range(x):
	ls[i] = map(float, input().split())
ls = map(sum, zip(*ls))
ls = list(map(lambda a: a / x, ls))
print(*ls, sep='\n')


(N, X) = map(int, input().split())
grades = []
for i in range(X):
	grades.append(list(map(float, input().split())))
zipped_grades = zip(*grades)
for j in zipped_grades:
	print(sum(j) / float(len(j)))


(N, X) = map(int, input().split())
l = []
for _ in range(X):
	l.append(map(float, input().split()))
unzipped = zip(*l)
for x in unzipped:
	print(sum(x) / len(x))


s1 = list(map(int, input().split()))
str1 = []
for i in range(0, s1[1]):
	str1 += [list(map(float, input().split()))]
s2 = list(map(sum, zip(*str1)))
for i in s2:
	print(i / s1[1])


(N, X) = map(int, input().split())
l = []
for _ in range(X):
	l.append(list(map(float, input().split())))
for i in zip(*l):
	print(sum(i) / X)


(a, b) = list(map(int, input().split()))
c = list()
for i in range(b):
	d = list(map(float, input().split()))
	c += [d]
e = zip(*c)
for i in e:
	print(sum(i) / b)


l = list(map(int, input().split()))
s = []
for i in range(l[1]):
	s.append(list(map(float, input().split())))
x = [s[0]]
for i in range(1, l[1]):
	x += [s[i]]
for j in zip(*x):
	print(sum(j) / l[1])


(m, n) = map(int, input().split())
res = []
for _ in range(n):
	res.append(map(float, input().split()))
for i in map(lambda x: x / n, map(sum, zip(*res))):
	print(i)


num_student = int(input().split()[1])
list_of_score = [[float(x) for x in input().split()] for y in range(num_student)]
avg = [sum(x) / num_student for x in zip(*list_of_score)]
for x in avg:
	print(x)


(x, n) = input().split()
x = int(x)
n = int(n)
res = []
for i in range(n):
	res.append([float(j) for j in input().split()])
res = [sum(i) / len(i) for i in zip(*res)]
for i in range(x):
	print(res[i])


(num_students, num_subjects) = map(int, input().split())
records = []
for i in range(num_subjects):
	records.append(list(map(float, input().split())))
records = list(zip(*records))
for i in records:
	print('%.1f' % (sum(i) / len(i)))


(N, X) = list(map(int, input().split()))
temp = []
for x in range(X):
	temp.append(tuple(map(float, input().split())))
for x in list(zip(*temp)):
	print(sum(x) / len(x))


(students, subjects) = [int(i) for i in input().split()]
Marks = []
for i in range(subjects):
	Marks.append(list([float(i) for i in input().split()]))
print('\n'.join([str(sum(i) / subjects) for i in zip(*Marks)]))


(n_students, n_subjects) = map(int, input().split())
results = []
for subject in range(n_subjects):
	results.append(map(float, input().split()))
for average in map(lambda x: x / n_subjects, map(sum, zip(*results))):
	print(average)


import sys
state = 0
num_students = 0
num_subjects = 0
total = []
counter = 0
for line in sys.stdin:
	if state == 0:
		(num_students, num_subjects) = [int(e) for e in line.strip().split(' ')]
		total = [[0] for i in range(num_students)]
		state = 1
	elif state == 1:
		scores = [float(e) for e in line.strip().split(' ')]
		[total[i].append(scores[i]) for i in range(num_students)]
		counter += 1
		if counter == num_subjects:
			result = list(map(lambda x: round(sum(x) / num_subjects, 1), total))
			for r in result:
				print(r)
			counter = 0
			state = 0


n = [int(x) for x in input().split()][1]
I = [[float(x) for x in input().split()] for _ in range(n)]
O = [sum(x) / n for x in zip(*I)]
for x in O:
	print(x)


(N, subjs) = list(map(int, input().split()))
vec = []
for i in range(subjs):
	vec.append(list(map(float, input().split())))
xvec = list(zip(*vec))
for i in range(N):
	print(sum(xvec[i]) / subjs)


(n, x) = [int(k) for k in input().split()]
lis = []
for _ in range(x):
	lis += [[float(k) for k in input().split()]]
for i in zip(*lis):
	s = 0
	for j in i:
		s += j
	print(s / x)


(n, x) = map(int, input().strip().split())
marks = []
for i in range(0, x):
	marks.append(input().strip().split())
for i in range(0, n):
	res = 0
	for j in range(0, x):
		res += float(marks[j][i])
	print(res / x)


(numStudent, numSubject) = [int(i) for i in input().split()]
scores = list()
for _ in range(numSubject):
	scores.append([float(i) for i in input().split()])
scoresByStudent = zip(*scores)
avgByStudent = [sum(x) / len(x) for x in scoresByStudent]
for avg in avgByStudent:
	print(avg)


(students, subjects) = map(int, input().split())
sheet = [None] * subjects
for subject in range(subjects):
	sheet[subject] = list(map(float, input().split()))
for x in zip(*sheet):
	print(sum(x) / subjects)


__author__ = 'namii'
(N, X) = map(int, input().split())
L = []
for line in range(X):
	contents = list(map(float, input().split()))
	L.append(contents)
for line in zip(*L):
	print(sum(line) / len(line))


(N, X) = input().split()
N = int(N)
X = int(X)
marks = [0] * X
for i in range(X):
	inputs = input().split()
	inputs = list(map(float, inputs))
	marks[i] = inputs[:N]
marks_tr = list(zip(*marks))
averages = [sum(e) / len(e) for e in marks_tr]
for a in averages:
	print(a)


(n, x) = map(int, input().strip().split())
grades = []
for i in range(x):
	grades.append(list(map(float, input().strip().split())))
newGrades = zip(*grades)
for s in newGrades:
	print(sum(s) / x)


(n, x) = map(int, input().split())
s = []
for i in range(x):
	s.append(list(map(float, input().split())))
import itertools
for i in list(zip(*s)):
	print(sum(i) / x)


(n, x) = map(int, input().split())
scores = list((list(map(float, input().split())) for _ in range(x)))
for e in zip(*scores):
	print(sum(e) / x)


(N, X) = map(int, input().split())
marks = [list(map(float, input().split())) for st in range(X)]
for i in range(N):
	print(sum((k for k in list(zip(*marks))[i])) / X)


(n, x) = map(int, input().split())
l = []
for i in range(x):
	l.append(list(map(float, input().split())))
l = list(zip(*l))
for i in range(len(l)):
	s = sum(l[i]) / x
	print(s)


(n, x) = map(int, input().split())
data = []
for i in range(x):
	data.append(list(map(float, input().split())))
for vals in zip(*data):
	print(sum(vals) / x)


import functools
[N, X] = list(map(int, input().split()))
scores = list(map(float, input().split()))
for _ in range(X - 1):
	scores = list(map(sum, zip(scores, list(map(float, input().split())))))
for score in scores:
	print(score / X)


(subject, students) = map(int, input().split())
data = []
for _ in range(students):
	data.append(list(map(float, input().split())))
zip_data = list(zip(*data))
for i in range(len(zip_data)):
	print(sum(zip_data[i]) / students)


(n, x) = map(int, input().split())
marks = []
for _ in range(x):
	m = list(map(float, input().split()))
	marks.append(m)
student_marks = zip(*marks)
for mark in student_marks:
	s = sum(mark)
	print(s / x)


(n, x) = list(map(int, input().split()))
ar = [0 for i in range(n)]
for i in range(x):
	temp_ar = list(map(float, input().split()))
	for j in range(n):
		ar[j] += temp_ar[j]
for i in range(n):
	print(ar[i] / x)