Array Mathematics

Sort by

recency

|

319 Discussions

|

  • + 0 comments
    import numpy as np
    n,m = list(map(int, input().split()))
    A = [list(map(int, input().split())) for _ in range(n)]
    B = [list(map(int, input().split())) for _ in range(n)]
    a = np.array(A)
    b = np.array(B)
    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))
    
  • + 0 comments

    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))

  • [deleted]Challenge Author
    + 0 comments

    For Python3

    import numpy as np
    
    n, m = map(int, input().split())
    A = []
    B = []
    
    for i in range(n):
        A.append([*map(int, input().split())])
    for j in range(n):
        B.append(list(map(int, input().split())))
    
    A = np.array(A)
    B = np.array(B)
    
    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))
    
  • + 0 comments

    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)

  • + 0 comments

    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