Python - Imprimir una matriz en Python

 
Vista:

Imprimir una matriz en Python

Publicado por Romario (1 intervención) el 04/12/2020 21:02:08
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import random
def matrix():
    M=[]
    for i in range(3):
        M.append([])
        for j in range(3):
            M[i].append(random.randint(1,10))
    print(MostrarMatrix(M))
 
def MostrarMatrix(M):
    for i in range(3):
        mostrar=[]
        for j in range(3):
            mostrar.append(M[i][j])
        print(mostrar)
 
def main():
    matrix()
 
#-----------------------------
main()
 
'''
[1, 5, 5]
[4, 4, 2]
[2, 3, 6]
'''
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de joel
Val: 3.475
Oro
Ha mantenido su posición en Python (en relación al último mes)
Gráfica de Python

Imprimir una matriz en Python

Publicado por joel (901 intervenciones) el 05/12/2020 13:49:37
Hola Romario, cual es tu duda?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar