sum    

The sum tool returns the sum of array elements over a given axis.  

import numpy

my_array = numpy.array([ [1, 2], [3, 4] ])

print numpy.sum(my_array, axis = 0)         #Output : [4 6]
print numpy.sum(my_array, axis = 1)         #Output : [3 7]
print numpy.sum(my_array, axis = None)      #Output : 10
print numpy.sum(my_array)                   #Output : 10

By default, the axis value is None. Therefore, it performs a sum over all the dimensions of the input array.

prod

The prod tool returns the product of array elements over a given axis.  

import numpy

my_array = numpy.array([ [1, 2], [3, 4] ])

print numpy.prod(my_array, axis = 0)            #Output : [3 8]
print numpy.prod(my_array, axis = 1)            #Output : [ 2 12]
print numpy.prod(my_array, axis = None)         #Output : 24
print numpy.prod(my_array)                      #Output : 24

By default, the axis value is None. Therefore, it performs the product over all the dimensions of the input array.

Task  

You are given a 2-D array with dimensions $N$X$\mbox{M}$. 

Your task is to perform the $\textit{sum}$ tool over axis $\mbox{o}$ and then find the $\textit{product}$ of that result.

Input Format

The first line of input contains space separated values of $N$ and $\mbox{M}$. 

The next $N$ lines contains $\mbox{M}$ space separated integers.

Output Format

Compute the sum along axis $\mbox{o}$. Then, print the product of that sum. 

Sample Input
2 2
1 2
3 4

Sample Output
24

Explanation

The sum along axis $\mbox{o}$ = [$\begin{array}{c}A\end{array}$ $\boldsymbol{6}$] 

The product of this sum = $24$

Difficulty: EASY

Starter code:

Solutions:
import numpy
(n, m) = map(int, input().split())
print(numpy.prod(numpy.sum(numpy.array([input().split() for _ in range(n)], int), axis=0)))


import numpy
(N, M) = map(int, input().split())
a = numpy.array([input().split() for i in range(N)], int)
b = numpy.sum(a, axis=0)
print(numpy.prod(b))


import numpy
(n, m) = [int(a) for a in input().split()]
arr = numpy.array([input().split() for a in range(m)], int)
arr_sum = numpy.sum(arr, axis=0)
print(numpy.prod(arr_sum))


import numpy
(N, M) = map(int, input().split())
print(numpy.prod(numpy.sum(numpy.array([list(map(int, input().split())) for _ in range(N)]), axis=0)))


import numpy
(N, M) = map(int, input().split())
A = numpy.array([input().split() for _ in range(N)], int)
B = numpy.sum(A, axis=0)
print(numpy.prod(B))


import numpy as np
(n, m) = [int(e) for e in input().split()]
l = [input().split() for i in range(n)]
a = np.array(l, int)
print(np.prod(np.sum(a, axis=0)))


import numpy
(N, M) = map(int, input().split())
A = numpy.array([list(map(int, input().split())) for n in range(N)])
print(numpy.prod(numpy.sum(A, axis=0), axis=0))


import numpy
(n, m) = list(map(int, input().split()))
ar = []
for i in range(n):
	tmp = list(map(int, input().split()))
	ar.append(tmp)
np_ar = numpy.array(ar)
s = numpy.sum(np_ar, axis=0)
print(numpy.prod(s))


import numpy
(n, m) = map(int, input().split())
print(numpy.prod(numpy.sum(numpy.array([list(map(int, input().split())) for _ in range(n)]), axis=0)))


import numpy
(N, M) = map(int, input().split())
NP = numpy.array([list(map(int, input().split())) for i in range(N)])
print(numpy.prod(numpy.sum(NP, axis=0)))


import numpy
(n, m) = map(int, input().split())
a = []
for _ in range(n):
	a.append(list(map(int, input().split())))
a = numpy.array(a)
print(numpy.prod(numpy.sum(a, axis=0)))


import numpy
(n, m) = [int(x) for x in input().split()]
a = []
for i in range(n):
	a.append([int(x) for x in input().split()])
a = numpy.array(a)
b = numpy.sum(a, axis=0)
print(numpy.prod(b))


import numpy as np
(n, m) = (int(x) for x in input().split(' '))
a = np.array([[int(x) for x in input().split()] for _ in range(n)])
print(a.sum(axis=0).prod())


import numpy
(n, m) = [int(e) for e in input().split()]
arr = []
for _ in range(n):
	arr.append([int(e) for e in input().split()])
arr = numpy.array(arr, dtype=int)
s = numpy.sum(arr, axis=0)
print(numpy.prod(s, axis=None))


import sys
import numpy as np
(n, m) = [int(x) for x in input().split()]
my_list = []
for _ in range(n):
	my_list.append([int(x) for x in input().split()])
my_array = np.array(my_list, dtype=int)
my_sum = np.sum(my_array, axis=0)
print(np.prod(my_sum))


import numpy
(N, M) = map(int, input().split())
l1 = []
for i in range(N):
	l1.append(numpy.array(input().split(), int))
l1 = numpy.array(l1)
l2 = []
s = numpy.sum(l1, axis=0)
print(numpy.prod(s))


import numpy
(n, m) = map(int, input().split())
l = list()
for _ in range(n):
	l.append(list(map(int, input().split())))
a = numpy.array(l, int)
a1 = numpy.sum(a, axis=0)
print(numpy.prod(a1))


import numpy
(N, M) = map(int, input().split())
A = numpy.array([list(map(int, input().split())) for _ in range(N)])
print(numpy.prod(numpy.sum(A, axis=0)))


import numpy as np
(n, m) = list(map(int, input().split()))
arr1 = []
for i in range(0, n):
	temp = list(map(int, input().split()))
	arr1.append(temp)
npa = np.array(arr1)
npa = np.sum(npa, axis=0)
npa = np.prod(npa)
print(npa)


import numpy
(N, M) = [int(x) for x in input().split()]
ll = []
for n in range(N):
	ll += [int(x) for x in input().split()]
a = numpy.array(ll).reshape(N, M)
print(numpy.prod(numpy.sum(a, axis=0), axis=0))


import numpy as np
(N, M) = [int(i) for i in input().split()]
A = np.array([input().split() for _ in range(N)], int)
s = np.sum(A, axis=0)
print(np.prod(s))


import numpy as np

def main():
	(n, m) = map(int, input().split())
	l = []
	for _ in range(n):
		l.append(list(map(int, input().split())))
	l = np.array(l)
	print(np.prod(np.sum(l, axis=0)))
main()


import numpy
(n, m) = map(int, input().split())
my_array = numpy.array([list(map(int, input().split())) for i in range(n)])
print(numpy.prod(numpy.sum(my_array, axis=0)))


import numpy
(n, m) = map(int, input().split())
mylist = []
for i in range(n):
	mylist.append(list(map(int, input().split())))
myarray = numpy.array(mylist)
print(numpy.prod(numpy.sum(myarray, axis=0)))


import numpy as np
(n, m) = [int(i) for i in input().split()]
a = np.zeros((n, m))
for i in range(n):
	a[i] = [int(j) for j in input().split()]
b = np.sum(a, axis=0)
print(int(np.prod(b)))


import numpy
nm = list(map(int, input().split()))
matrix = numpy.array(numpy.zeros((nm[0], nm[1])))
values = []
for i in range(nm[0]):
	values.extend(list(map(int, input().split())))
matrix = numpy.array(values)
matrix.shape = (nm[0], nm[1])
print(numpy.prod(numpy.sum(matrix, axis=0)))


import numpy
(N, M) = map(int, input().split())
a = numpy.array([list(map(int, input().split())) for _ in range(N)])
print(numpy.prod(numpy.sum(a, axis=0)))


import numpy
(N, M) = map(int, input().split())
a = []
for i in range(N):
	a.append(list(map(int, input().split())))
a = numpy.array(a)
print(numpy.product(numpy.sum(a, axis=0)))


import numpy
(n, m) = [int(x) for x in input().split()]
array_a = []
for _ in range(n):
	array_a.append([int(x) for x in input().split()])
array_a = numpy.array(array_a)
axis_sum = numpy.sum(array_a, axis=0)
axis_product = numpy.product(axis_sum)
print(axis_product)


import numpy as np
l = list(map(int, input().split()))
array = []
for i in range(l[0]):
	array.append(list(map(int, input().split())))
np_array = np.array(array)
print(np.prod(np.sum(np_array, axis=0)))


import numpy
print(numpy.product(numpy.sum(numpy.array([[int(x) for x in input().split()] for _ in range(int(input().split()[0]))]), axis=0)))


import numpy
mojir = input()
hyo = mojir.split(' ')
N = int(hyo[0])
M = int(hyo[1])
motoarr = []
for idx in range(0, N, 1):
	mojir = input()
	hyo = mojir.split(' ')
	yokovec = [int(mono) for mono in hyo]
	motoarr.append(yokovec)
arr = numpy.array(motoarr)
totyuuvec = numpy.sum(arr, axis=0)
print(numpy.prod(totyuuvec))


import numpy
(n, m) = map(int, input().strip().split())
arr = numpy.array([list(map(int, input().strip().split())) for line in range(n)])
print(numpy.prod(numpy.sum(arr, axis=0)))


from numpy import array, prod, sum
(N, M) = map(int, input().split())
num = []
for _ in range(N):
	num.append(list(map(int, input().split())))
num = array(num)
print(prod(sum(num, axis=0)))


import numpy
(n, m) = map(int, input().split())
a = numpy.array([input().split() for i in range(n)], int)
print(numpy.prod(numpy.sum(a, axis=0)))


import numpy
(n, m) = tuple((int(x.strip()) for x in input().split()))
in_list = []
for i in range(n):
	in_list.append([k for k in input().split()])
arr = numpy.array(in_list, int)
sum_arr = numpy.sum(arr, axis=0)
print(numpy.prod(sum_arr))


import numpy as np
(N, M) = map(int, input().split())
matrix = np.empty((N, M), dtype=int)
for i in range(N):
	inp = input()
	matrix[i] = np.array(list(map(int, inp.split())))
result1 = np.sum(matrix, axis=0)
result2 = np.prod(result1, axis=None)
print(result2)


import operator
import numpy

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

def read_f_words(f):
	return mapl(f, input().split())

def mapl(f, x):
	return list(map(f, list(x)))
nm = read_f_words(int)
(n, m) = nm
ns = []
for x in range(n):
	ns.append(read_f_words(int))
a0 = numpy.array(ns)
print(numpy.prod(numpy.sum(a0, axis=0)))


import numpy
(n, m) = map(int, input().split())
array = [list(map(int, input().split())) for i in range(n)]
print(numpy.prod(numpy.sum(array, axis=0), None))


import numpy
(n, m) = tuple(map(int, input().split()))
array = numpy.array([list(map(int, input().split())) for i in range(n)])
array_sum = numpy.sum(array, axis=0)
print(numpy.product(array_sum))


import numpy
(n, m) = (int(i) for i in input().split())
l = []
for _ in range(n):
	l.append(input().split())
print(numpy.prod(numpy.sum(numpy.array(l, int), axis=0)))


from numpy import *
(N, M) = map(int, input().strip().split())
print(product(sum(array([[int(x) for x in input().strip().split()] for _ in range(N)]), axis=0)))


import numpy
A = numpy.array([numpy.array(input().split(), int) for _ in range(int(input().split()[0]))])
print(numpy.prod(numpy.sum(A, axis=0)))


import numpy as np
import sys
(N, M) = list(map(int, sys.stdin.readline().split()))
A = np.array([sys.stdin.readline().split() for _ in range(N)], int)
print(np.product(np.sum(A, axis=0)))


import numpy
(n, m) = map(int, input().split())
arr = []
for i in range(0, n):
	arr.append([int(x) for x in input().split()])
my_arr = numpy.array(arr)
my_sum = numpy.sum(my_arr, axis=0)
print(numpy.prod(my_sum))


import numpy
(n, m) = map(int, input().split())
data = numpy.array([input().split() for _ in range(n)], int)
print(numpy.prod(numpy.sum(data, axis=0)))


import numpy
(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.extend(list(map(int, input().split())))
a = numpy.array(a)
a.shape = (n, m)
print(numpy.prod(numpy.sum(a, axis=0)))


import numpy
print(numpy.prod(numpy.sum(numpy.array([input().split() for _ in range(int(input().split()[0]))], int), axis=0)))


import numpy
(n, m) = map(int, input().split())
A = numpy.array([list(map(int, input().split())) for i in range(n)])
print(numpy.prod(numpy.sum(A, axis=0)))


import numpy
(n, m) = map(int, input().split())
arrays = list()
for i in range(n):
	arrays.append(list(map(int, input().split())))
my_array = numpy.array(arrays)
print(numpy.prod(numpy.sum(my_array, axis=0)))


import numpy
(N, M) = map(int, input().split())
a = numpy.array([list(map(int, input().split())) for i in range(N)])
b = numpy.sum(a, axis=0)
print(numpy.prod(b))


import numpy as np
(n, m) = map(int, input().split())
a = np.array([list(map(int, input().split())) for _ in range(n)])
a = a.sum(axis=0)
print(np.prod(a))


import numpy
i = [i for i in map(int, input().split())]
(N, M) = (i[0], i[1])
a = []
for i in range(N):
	a.append([i for i in map(int, input().split())])
a_array = numpy.array(a)
a_array_sum = numpy.sum(a_array, axis=0)
a_array_sum_prod = numpy.prod(a_array_sum)
print(a_array_sum_prod)


from numpy import array, sum, prod
(N, M) = map(int, input().strip().split())
A = array([[int(i) for i in input().strip().split()] for _ in range(N)])
print(prod(sum(A, axis=0)))


import numpy as np
(n, m) = map(int, input().split())
liso = []
for i in range(n):
	liso.append(list(map(int, input().split())))
arr = np.array(liso)
print(np.prod(np.sum(arr, axis=0)))


import numpy
(N, M) = tuple(map(int, input().split()))
iArr = numpy.array([list(map(int, input().split())) for i in range(N)])
print(numpy.product(numpy.sum(iArr, axis=0)))


import numpy
(n, m) = list(map(int, input().strip().split()))
o = 1
arr = numpy.array([list(map(int, input().strip().split())) for i in range(n)])
for i in range(len(numpy.sum(arr, axis=0))):
	o *= numpy.sum(arr, axis=0)[i]
print(o)


import numpy as np
(n, m) = map(int, input().split())
print(np.prod(np.sum(np.array([list(map(int, input().split())) for _ in range(n)]), axis=0)))


import numpy as np
(n, m) = map(int, input().split(' '))
arr = np.array([input().strip().split(' ') for i in range(m)], int)
print(np.prod(np.sum(arr, axis=0)))


import numpy
(n, m) = map(int, input().split())
A = [0] * n
for i in range(n):
	A[i] = list(map(int, input().split()))
A = numpy.array(A, int)
A = numpy.sum(A, axis=0)
res = numpy.prod(A)
print(res)


import numpy
metrics = list(map(int, input().split()))
n = metrics[0]
m = metrics[1]
a = []
for i in range(n):
	var = list(map(int, input().split()))
	a.append(var)
a = numpy.array(a)
asum = numpy.sum(a, axis=0)
print(numpy.prod(asum))


import numpy
(n, m) = [int(i) for i in input().strip().split()]
A = numpy.array([[int(i) for i in input().strip().split()] for j in range(n)])
S = numpy.sum(A, axis=0)
print(numpy.product(S))


import numpy
a = numpy.array(input().split(), int)
b = []
c = numpy.array([b + input().split() for i in range(a[0])], int)
c.shape = (a[0], a[1])
b = numpy.prod(numpy.sum(c, axis=0))
print(b)


import numpy as np
(n, m) = [int(x) for x in input().strip().split()]
array = np.array([[int(x) for x in input().strip().split()] for _ in range(n)])
print(np.prod(np.sum(array, axis=0)))


import numpy
(n, m) = tuple(map(int, input().strip().split()))
arr = numpy.array([list(map(int, input().strip().split())) for _ in range(n)])
print(numpy.prod(numpy.sum(arr, axis=0)))


from numpy import *
(n, m) = map(int, input().split())
mat = array([[int(x) for x in input().split()] for _ in range(n)])
print(prod(sum(mat, axis=0)))


import numpy
(N, M) = map(int, input().split())
A = numpy.array([input().split() for _ in range(N)], int)
print(A.sum(axis=0).prod())


import numpy
a = []
for _ in range(int(input().strip().split()[0])):
	a.append(list(map(int, input().strip().split())))
print(numpy.prod(numpy.sum(a, 0)))


import numpy
(n, m) = [int(x) for x in input().split()]
A = []
for _ in range(n):
	A.append([int(x) for x in input().split()])
A = numpy.array(A, int)
print(numpy.prod(numpy.sum(A, axis=0)))


import numpy as np
i = input().split()
arr = np.array([input().split() for _ in range(int(i[0]))], dtype=int)
print(np.prod(np.sum(arr, axis=0)))


import numpy
arr = []
for i in range(int(input().split()[0])):
	arr.append(list(map(int, input().split())))
a = numpy.array(arr, int)
s = numpy.sum(arr, axis=0)
print(numpy.prod(s))


import numpy
n = int(input().split()[0])
arr = numpy.array([input().split() for _ in range(n)], int)
print(numpy.prod(numpy.sum(arr, axis=0)))


import numpy
(n, m) = map(int, input().split())
l = []
for i in range(m):
	l.append(list(map(int, input().split())))
k = numpy.sum(l, axis=0)
print(numpy.prod(k))


import numpy as np
a = list(map(int, input().split(' ')))
N = a[0]
M = a[1]
array = np.array([[0 for j in range(M)] for i in range(N)])
for i in range(N):
	temp = list(map(int, input().split(' ')))
	for j in range(M):
		array[i][j] = temp[j]
sum = np.sum(array, axis=0)
print(np.prod(sum))


import numpy
(N, M) = map(int, input().split())
A = list()
for i in range(N):
	A.append(input().split())
ListA = numpy.array(A, int)
print(numpy.prod(numpy.sum(ListA, axis=0)))


import numpy
(n, _) = (int(i) for i in input().split())
a = numpy.array(tuple((input().split() for _ in range(n))), int)
print(numpy.prod(numpy.sum(a, axis=0)))


import numpy
(N, M) = list(map(int, input().split(' ')))
array = []
for i in range(N):
	row = list(map(int, input().split(' ')))
	array.append(row)
array = numpy.array(array)
s = numpy.sum(array, axis=0)
p = numpy.prod(s)
print(p)


import numpy as np
[N, M] = list(map(int, input().split()))
L1 = []
for i in range(N):
	L1.append(list(map(int, input().split())))
npArr = np.array(L1)
print(np.prod(np.sum(npArr, axis=0)))


import numpy
(N, M) = map(int, input().split())
A = numpy.array([input().split() for _ in range(N)], int)
print(numpy.prod(numpy.sum(A, axis=0)))


import numpy as np
(n, m) = tuple(map(int, input().split()))
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
a = np.array(a)
a = np.sum(a, axis=0)
print(np.prod(a))


import numpy as np
import numpy as np
(n, m) = map(int, input().split())
a = np.fromstring(' '.join([input() for _ in range(n)]), sep=' ', dtype=int).reshape(n, m)
print(a.sum(0).prod())


import numpy
dims = tuple(map(int, input().split(' ')))
data = [numpy.array(input().split(' '), int) for i in range(dims[0])]
print(numpy.prod(numpy.sum(data, axis=0)))


import numpy
(n, m) = map(int, input().split())
a = numpy.array([input().split() for i in range(n)], int)
a = numpy.sum(a, axis=0)
print(numpy.prod(a, axis=0))


import numpy
(N, M) = list(map(int, input().split()))
A = []
for i in range(N):
	A.append(list(map(int, input().split())))
print(numpy.prod(numpy.sum(A, axis=0)))


import numpy
(n, _) = map(int, input().split())
array = numpy.array([list(map(int, input().split())) for _ in range(n)])
print(numpy.prod(numpy.sum(array, axis=0)))


import numpy
(n, m) = map(int, input().split())
a = numpy.array([list(map(int, input().split())) for i in range(n)])
print(numpy.prod(numpy.sum(a, 0)))


import numpy
(N, M) = [int(x) for x in input().split()]
L = []
for i in range(N):
	L.append([int(x) for x in input().split()])
A = numpy.array(L)
S = numpy.sum(A, axis=0)
print(numpy.prod(S))


import numpy
(n, m) = map(int, input().split(' '))
print(numpy.prod(numpy.sum(numpy.array([input().split(' ') for _ in range(m)], int), axis=0)))


import numpy
(N, M) = map(int, input().split())
r = []
for _ in range(N):
	r.append(list(map(int, input().split())))
r = numpy.array(r)
print(numpy.prod(numpy.sum(r, axis=0)))


import numpy
(n, m) = map(int, input().split())
a = numpy.array([[int(e) for e in input().split()] for i in range(n)])
b = numpy.sum(a, axis=0)
print(numpy.prod(b))


import numpy as np
(N, M) = [int(x) for x in input().split(' ')]
arr = []
for _ in range(N):
	arr.append([int(x) for x in input().split(' ')])
a = np.array(arr).reshape(N, M)
print(np.prod(np.sum(a, axis=0)))


import numpy
(N, M) = map(int, input().strip().split())
A = numpy.array([list(map(int, input().strip().split())) for x in range(N)])
print(numpy.prod(numpy.sum(A, axis=0)))


import numpy as np
(n, m) = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
print(np.prod(np.sum(a, axis=0), axis=0))


import numpy
(n, m) = map(int, input().split())
arr = numpy.array([list(map(int, input().split())) for allvals in range(0, n)])
print(numpy.prod(numpy.sum(arr, axis=0)))


import numpy
(n, m) = map(int, input().split())
my_array = numpy.array([input().split() for _ in range(n)], int)
print(numpy.prod(numpy.sum(my_array, axis=0)))


import numpy
(n, m) = list(map(int, input().split()))
A = numpy.array([list(map(int, input().split())) for i in range(n)])
print(numpy.prod(numpy.sum(A, axis=0)))


import numpy
(N, M) = list(map(int, input().split()))
A = numpy.array([input().split() for _ in range(N)], int)
print(numpy.product(numpy.sum(A, axis=0)))


import numpy
(n, m) = map(int, input().strip().split())
a = []
for i in range(n):
	a.append(list(map(int, input().strip().split())))
a = numpy.array(a)
print(numpy.product(numpy.sum(a, axis=0)))