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
- Array Mathematics
- Discussions
Array Mathematics
Array Mathematics
Sort by
recency
|
319 Discussions
|
Please Login in order to post a comment
import numpy as np
m , n = map(int, input().split(" ")) a = np.array(list(map(int, input().split(" ")))) b = np.array(list(map(int, input().split(" "))))
print(np.add(a,b)) print(np.subtract(a,b)) print(np.multiply(a,b)) print(np.floor_divide(a,b)) print(np.mod(a,b)) print(np.power(a,b))
For Python3
import numpy
line=input() n=int(line.split()[0]) m=int(line.split()[1]) a=[] b=[] for i in range(n): m=list(map(int,input().split())) a.append(m)
a=numpy.array(a)
for i in range(n): m=list(map(int,input().split())) b.append(m)
b=numpy.array(b)
print(a+b) print(a-b) print(a*b) print(a//b) print(a%b) print(a**b)
import numpy N, M = map(int, input().strip().split()) arr_1 = numpy.array([input().strip().split() for _ in range(N)][:M], dtype=numpy.int_) arr_2 = numpy.array([input().strip().split() for _ in range(N)][:M], dtype=numpy.int_) print(numpy.add(arr_1, arr_2)) #arr_1 + arr_2 print(numpy.subtract(arr_1, arr_2)) #arr_1 - arr_2 print(numpy.multiply(arr_1, arr_2)) #arr_1 * arr_2 print(numpy.floor_divide(arr_1, arr_2)) #arr_1 // arr_2 print(numpy.mod(arr_1, arr_2)) #arr_1 % arr_2 print(numpy.power(arr_1, arr_2)) #arr_1 ** arr_2