Advertisement
teslariu

for matriz

Jan 14th, 2022
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Script que imprime una matriz
  4. """
  5. matriz = 5 2 8 7
  6. 1 3 21 -8
  7. 4 12 5 4
  8.  
  9. """
  10. matriz = [ [5,2,8,7], [1,3,21,-8], [4,12,5,4] ]
  11.  
  12. # formas de imprimir una matriz
  13. print("Impresion lineal")
  14. print(matriz)
  15.  
  16. print("\nImpresión 2D")
  17. for fila in matriz:
  18. print(fila)
  19.  
  20. print("\nOtra forma de impresión 2D")
  21. for fila in matriz:
  22. for numero in fila:
  23. print(numero, end=" ")
  24. print()
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement