You are given m*n matrix and k write a program to compute the area of submatrix
import numpy as np
def print_mat(m, n, k):
list1 = []
j = 1
r = 1
for i in range(m * n):
list1.append(int(input('Enter number here: ')))
list1 = np.array(list1)
list1 = np.reshape(list1, (m, n))
s = list1[k:m-k, k:n-k]
for i in s:
j = j * i
for i in j:
r = r * i
return r
print_mat(5,4,1)
Enter number here: 1
Enter number here: 2
Enter number here: 3
Enter number here: 4
Enter number here: 5
Enter number here: 6
Enter number here: 7
Enter number here: 8
Enter number here: 9
Enter number here: 10
Enter number here: 11
Enter number here: 12
Enter number here: 13
Enter number here: 14
Enter number here: 15
Enter number here: 16
Enter number here: 17
Enter number here: 18
Enter number here: 19
Enter number here: 20
Out[17]:
970200
Comments
Leave a comment