generate functionMon, 13 Mar 2023

A natural number N is entered (that is, a positive integer). It is required to create a two-dimensional (nested) list of N x N elements, consisting of all ones, and then write fives in the last column. Display this list on the screen as a table of numbers, as shown in the example below. P.S. Be careful there should be no spaces at the end of the lines!

def fives(n): matrix = [] for i in range(n): matrix.append([]) for j in range(n): if j == n-1: matrix[i].append(5) else: matrix[i].append(1) for i in range(n): for j in range(n): print(matrix[i][j], end='') print() fives(10)

Questions about programming?Chat with your personal AI assistant