“Cómo hacer una matriz 2D en Python” Código de respuesta

2d matriz en Python


# Creates a list containing 5 lists, each of 8 items, all set to 0
w, h = 8, 5
Matrix = [[0 for x in range(w)] for y in range(h)] 

Better Bear

Python de matriz bidimensional

# Creates a list containing 5 lists, each of 8 items, all set to 0
w, h = 8, 5;
Matrix = [[0 for y in range(h)] for x in range(w)] 

Matrix[0][0] = 1
Matrix[0][6] = 3 # error! range... 
Matrix[6][0] = 3 # valid
Homely Hamerkop

Crea una matriz 2D en Python

def build_matrix(rows, cols):
    matrix = []

    for r in range(0, rows):
        matrix.append([0 for c in range(0, cols)])

    return matrix

if __name__ == '__main__':
    build_matrix(6, 10)
McBurd

2d matriz en Python

from array import *

T = [[11, 12, 5, 2], [15, 6,10], [10, 8, 12, 5], [12,15,8,6]]
for r in T:
    for c in r:
        print(c,end = " ")
    print()
Defiant Duck

Cómo hacer una matriz 2D en Python

grid_state = [['empty' for row in range(6)] for column in range(6)]
print(grid_state)
Yumna Hassan

2d matriz en Python

l = np.zeros(shape=(2,2))
stxrship

Respuestas similares a “Cómo hacer una matriz 2D en Python”

Preguntas similares a “Cómo hacer una matriz 2D en Python”

Más respuestas relacionadas con “Cómo hacer una matriz 2D en Python” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código