Situatie
Suppose we have two matrices A and B. A = [[1,2],[3,4]] B = [[4,5],[6,7]] then we get A+B = [[5,7],[9,11]] A-B = [[-3,-3],[-3,-3]]
Backup
# importing numpy as npimport numpy as np # creating first matrixA = np.array([[1, 2], [3, 4]]) # creating second matrixB = np.array([[4, 5], [6, 7]]) print("Printing elements of first matrix")print(A)print("Printing elements of second matrix")print(B) # adding two matrixprint("Addition of two matrix")print(np.add(A, B))
Leave A Comment?