Task-
-Subtraction of two matrix
For subtraction of two matrix , there shape(order) must be same.
Example-
first matrix is :
[[2 2]
[1 1]]
second matrix is :
[[1 0]
[0 1]]
Then subtraction of second matrix by first matrix is :
[[1 2]
[1 0]]
program-
#import numpy
import numpy as np
l=[[1,2,3],[4,5,1],[1,1,1]]
arr1=np.array(l)
print("nMatrix1 is :n",arr1)
l=[[1,2,3],[0,0,0],[1,1,0]]
arr2=np.array(l)
print("nMatrix 2 is :n",arr2)
print("nSubtraction of second matrix by first matrix is n",arr1-arr2)
Matrix1 is :
[[1 2 3]
[4 5 1]
[1 1 1]]
Matrix 2 is :
[[1 2 3]
[0 0 0]
[1 1 0]]
Subtraction of second matrix by first matrix is
[[0 0 0]
[4 5 1]
[0 0 1]]