you are given m*n matrix write a program to compute the parameter of matrix and print the result
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}')
Comments
Leave a comment