Answer to Question #312000 in Python for mahesh

Question #312000

you are given m*n matrix write a program to compute the parameter of matrix and print the result



1
Expert's answer
2022-03-15T10:15:09-0400
matrix=[]
print('Enter m: ', end='')
m = int(input())
print('Enter n: ', end='')
n = int(input())
print('Enter matrix (sep. space):')
for i in range(m):
    a = input().split()
    matrix.append([])    
    for j in range(n):
        matrix[i].append(int(a[j]))
sum = 0
for j in range(0, n):   
   sum = sum + matrix[0][j]+ matrix[m-1][j]
for i in range(1, m-1):
   sum = sum + matrix[i][0]+ matrix[i][n-1]

print(f'Perimeter= {sum}')

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