Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main() :
- row = int(input("Enter the number of rows in both the matrices : "))
- col = int(input("Enter the number of column in both the matrices : "))
- M1 , M2 , sum_mat = [],[],[]
- for i in range(2) :
- for j in range(row) :
- temp = []
- for k in range(col) :
- if i == 0 :
- elem = eval(input("Enter the Element of the First Matrix at the Position Row : {} , Column : {} =====> ".format(j+1,k+1)))
- else : elem = eval(input("Enter the Element of the Second Matrix at the Position Row : {} , Column : {} =====> ".format(j+1,k+1)))
- temp.append(elem)
- if i == 0 : M1.append(temp)
- else : M2.append(temp)
- print('\nMatrix A : ')
- for l in M1 : print(l)
- print("\nMatrix B : ")
- for m in M2 : print(m)
- temp = []
- for i in range(row) :
- for j in range(col) :
- sum_elem = M1[i][j] - M2[i][j]
- temp.append(sum_elem)
- sum_mat.append(temp)
- temp = []
- print("\nResult Of Subtraction : ")
- for i in sum_mat : print(i)
- main()
Add Comment
Please, Sign In to add comment