m=3n=4b = [[m]*n for x in range(n)]for i in range (m): for j in range (n): b[i][j]=(i*j+i+j) print (b[i][j],end=' ') print ()print (b) print ()
0 1 2 3 1 3 5 7 2 5 8 11
[[0, 1, 2, 3], [1, 3, 5, 7], [2, 5, 8, 11], [3, 3, 3, 3]]
for j in range (m): print (b[j]) print ()print ()
[0, 1, 2, 3][1, 3, 5, 7][2, 5, 8, 11]
m=3n=4print ('b=[[0] * n for i in range (m)]\n')b=[[m] * n for i in range (m)]print (b) #[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]print ()for i in range (m): for j in range (n): b[i][j]=(i+j) print (b[i][j],end=' ') print ()'''0 1 2 3 1 2 3 4 2 3 4 5'''print (b) # [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]]
m=3 n=4 print ('b=[[0] * n for i in range (n)]\n') b=[[m] * n for i in range (n)] print (b) #[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] print () for i in range (n): for j in range (n): b[i][j]=(i+j) print (b[i][j],end=' ') print () ''' 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 ''' print (b) # [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]
print ('array None: [[None for col in range(5)] for row in range(3)]\n') #inicializa una matriz mxn a Nonearray = [[None for col in range(5)] for row in range(3)]print (array)#[[None, None, None, None, None], [None, None, None, None, None], [None, None, None, None, None]]print ()print (' array2D a 0 = [[0 for col in range(5)] for fil in range(3)]\n' ) ##inicializa una matriz mxn a cerosarray2D = [[0 for col in range(5)] for row in range(3)]print (' array2D')print (array2D)'''array2D[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]'''print ()m = int(input("Filas: "))n = int(input("Columnas: "))'otro array None'print ('c=[[None]*n for i in range(m)]\n')c=[[None]*n for i in range(m)]print (c,'\n')#[[None, None, None, None], [None, None, None, None], [None, None, None, None]] for i in range (m): for j in range (n): c[i][j]=(j-i) print (c[i][j],end=' ') print ()'''0 1 2 3 -1 0 1 2 -2 -1 0 1'''print (c,'\n') #[[0, 1, 2, 3], [-1, 0, 1, 2], [-2, -1, 0, 1]] print ('c=c=[[0] * n for i in range (m)]\n')c=[[0] * n for i in range (m)] #inicializa una matriz mxn a cerosprint (c)for i in range (m): for j in range (n): c[i][j]=(i+j+i*j) print (c[i][j],end=' ') print ()print (c)print ()print ('a=[] y m a[i].append(i+j)\n')a=[]for i in range (m): a.append([]) for j in range (n): a[i].append(i+j) print (a[i][j],end=' ') print ()print ()'''0 1 2 3 1 2 3 4 2 3 4 5'''print ('b=[[0] * n for i in range (m)]\n')b=[[0] * n for i in range (m)]print (b) #[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]print ()for i in range (m): for j in range (n): b[i][j]=(i+j) print (b[i][j],end=' ') print ()'''0 1 2 3 1 2 3 4 2 3 4 5'''print (b) # [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]]for j in range (m): print (b[j]) print ()print ()'''[0, 1, 2, 3][1, 3, 5, 7][2, 5, 8, 11]'''print (b)print ('tabla: [[ 0 for i in range(n) ] for j in range(m)]\n')tabla= [[ 0 for i in range(n) ] for j in range(m)]print (tabla) #[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]for i in range (m): for j in range (n): tabla[i][j]=(i*j+i+j) print (tabla[i][j],end=' ') print ()'''0 1 2 3 1 3 5 7 2 5 8 11'''print (tabla) # [[0, 1, 2, 3], [1, 3, 5, 7], [2, 5, 8, 11]]print ()b=[[None] * n for i in range (m)]for i in range (m): for j in range (n): b[i][j]=(i*j+i+j) print (b[i][j],end=' ') print ()print (b) # [[0, 1, 2, 3], [1, 3, 5, 7], [2, 5, 8, 11]]print ()'''0 1 2 3 1 3 5 7 2 5 8 11'''