Write a program to copy a given array
Topic: Write a program to copy a given array
Solution
M = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]] rows = len(M) cols = len(M[0]) MC = [] while len(MC) < rows: MC.append([]) while len(MC[-1]) < cols: MC[-1].append(0.0) for i in range(rows): for j in range(cols): MC[i][j] = M[i][j] print("Copied Array") for i in range(rows): row = '|' for b in range(cols): row = row + ' ' + str(MC[i][b]) print(row + ' ' + '|')
List all Python Programs