1from array import *
2
3T = [[11, 12, 5, 2], [15, 6,10], [10, 8, 12, 5], [12,15,8,6]]
4for r in T:
5 for c in r:
6 print(c,end = " ")
7 print()
1def build_matrix(rows, cols):
2 matrix = []
3
4 for r in range(0, rows):
5 matrix.append([0 for c in range(0, cols)])
6
7 return matrix
8
9if __name__ == '__main__':
10 build_matrix(6, 10)
1# 2D arrays in python can be used to create rudimentary games
2
3array_2d = [['row0, column0'], ['row0, column1'], ['row0, column2'],
4 ['row1, column0'], ['row1, column1'], ['row1, column2'],
5 ['row2, column0'], ['row2, column1'], ['row2, column2']]
6
1# 2D array that is 3x4 (3 columns, 4 rows)
2# note that it is essentially an array of lists
3arr = [
4 [11, 12, 5],
5 [15, 6, 10],
6 [10, 8, 12],
7 [12, 15, 8]
8 ]