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.
- Prepare
- Python
- Numpy
- Sum and Prod
- Discussions
Sum and Prod
Sum and Prod
Sort by
recency
|
373 Discussions
|
Please Login in order to post a comment
import numpy as np n , m = [int(c) for c in input().split()] nparr = np.empty(shape=(n, m),dtype = 'i4')
print(n ,m)
print(nparr)
for i in range(n): lst = [int(c) for c in input().split()] for j in range(m): nparr[i][j] = lst[j] nparr = np.sum(nparr, axis=0) nparr = np.prod(nparr) print(nparr)
My compact solution…
If the
import
lines didn't count, this could be considered a one-liner.Here is HackerRank Sum and Prod in Python solution - https://programmingoneonone.com/hackerrank-sum-and-prod-problem-solution-in-python.html