“Créez un tableau 2D en Python” Réponses codées

Tableau 2D 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

Tableau 2D en python

# Using above first method to create a
# 2D array
rows, cols = (5, 5)
arr = [[0]*cols]*rows
print(arr)
Amir Jb

Créez un tableau 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

Tableau 2D 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

Comment faire un tableau 2D en Python

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

Tableau 2D en python

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

Réponses similaires à “Créez un tableau 2D en Python”

Questions similaires à “Créez un tableau 2D en Python”

Plus de réponses similaires à “Créez un tableau 2D en Python” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code