Last active
August 29, 2015 13:59
-
-
Save ricardosiri68/10536808 to your computer and use it in GitHub Desktop.
Se trata de ingresar un vector de orden 3, a partir de el generar un matriz de orden 3xN. Donde los elementos de la matriz deben ser: La primera fila contendra los elementos del vector. La segunda fila contendra el duplo del vector. La tercera fila contendra el triple del vector.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
def generar_vector(n): | |
''' | |
genera un vector con enteros aleatoreos entre 0-1000 de longitud n | |
''' | |
return [randint(0, 1000) for i in range(n)] | |
def generar_matriz(n): | |
''' | |
genera la matriz del vector permutado segun n | |
''' | |
vector = generar_vector(n) | |
return [[b * a for b in vector] for a in range(1, n + 1)] | |
if __name__ == "__main__": | |
for v in generar_matriz(3): | |
strVector = " |".join([m for m in map(lambda x: "%6d" % x, v)]) | |
print(strVector) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment