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
|
316 Discussions
|
Please Login in order to post a comment
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
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 as np
N,M = map(int,input().split()) A =np.array([list(map(int,input().split()))for _ in range(N)]) B = np.array([list(map(int,input().split()))for _ in range(N)])
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))