SHARE
TWEET

Untitled

a guest May 22nd, 2019 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def llenar_lista(lista, n, tipo = "t"):
  2.     if tipo == "t":
  3.         for i in range(n):
  4.             lista.append(input())
  5.     elif tipo == "i":
  6.         for i in range(n):
  7.             lista.append(int(input()))
  8.  
  9. def separa_lista(lista, impares):
  10.     pares = []
  11.     impares = []
  12.     for i in lista:
  13.         if i % 2 == 0:
  14.             pares.append(i)
  15.         else:
  16.             impares.append(i)
  17.     return pares
  18.  
  19. def primera_ocurrencia(lista, buscar):
  20.     for i in range(len(lista)):
  21.         if lista[i].lower() == buscar.lower():
  22.             return i
  23.     return "NF"
  24.  
  25. def separa_voccon(lista):
  26.     vocales = []
  27.     consonantes = []
  28.     for i in lista:
  29.         if i[0] in ["a", "e", "i", "o", "u"]:
  30.             vocales.append(i)
  31.         else:
  32.             consonantes.append(i)
  33.     return vocales, consonantes
  34.  
  35. def elimina_dups(lista):
  36.     i = 0
  37.     while i < len(lista):
  38.         j = i + 1
  39.         while j < len(lista):
  40.             if lista[j] == lista[i]:
  41.                 lista.pop(j)
  42.             j += 1
  43.         i += 1
  44.  
  45. def print_matriz(matriz):
  46.     for i in range(len(matriz)):
  47.         for j in range(len(matriz[i])):
  48.             print(matriz[i][j], "", end="")
  49.         print()
  50.  
  51. def suma_filas(matriz):
  52.     res = []
  53.     for i in range(len(matriz)):
  54.         sum = 0
  55.         for j in range(len(matriz[i])):
  56.             sum += matriz[i][j]
  57.         res.append(sum)
  58.     return res
  59.  
  60. def suma_columnas(matriz):
  61.     res = []
  62.     for i in range(len(matriz[0])):
  63.         sum = 0
  64.         for j in range(len(matriz)):
  65.             sum += matriz[j][i]
  66.         res.append(sum)
  67.     return res
  68.  
  69. matriz = [[1, 2, 3],
  70.           [4, 5, 6]]
  71.  
  72. print(suma_columnas(matriz))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top