Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I wrote such a code, but when I run it, the last two columns are missing. I think the problem is in the n matrix

I wrote such a code, but when I run it, the last two columns are missing. I think the problem is in the n matrix length, but couldnt solve the problem def task03(matrix): n = len(matrix) substituted = 0 P = [[0] * n for _ in range(n)] for i in range(n): for j in range(n): if matrix[i][j] != 0: P[i][j] = matrix[i][j] else: row_sum = sum(matrix[i][j + 1:]) col_sum = sum(matrix[k][j] for k in range(i)) P[i][j] = row_sum + col_sum substituted += row_sum + col_sum if n <= 20: print(' '.join(' '.join(str(P[i][j]) for j in range(n)) for i in range(n))) else: right_bottom_submatrix = [row[-20:] for row in P[-20:]] print(' '.join(' '.join(str(right_bottom_submatrix[i][j]) for j in range(20)) for i in range(20))) print(substituted)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions