Answer to Question #303450 in Python for Ash

Question #303450

You are given m*n matrix and k write a program to compute the area of submatrix

1
Expert's answer
2022-02-28T01:05:59-0500
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS