Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created October 11, 2020 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/55239595a9f25e166497b3382eb532b7 to your computer and use it in GitHub Desktop.
Save parzibyte/55239595a9f25e166497b3382eb532b7 to your computer and use it in GitHub Desktop.
# https://parzibyte.me/blog
arreglo = [10, 7, 6, 10, 4, 9, 10, 5, 9, 8, 4, 3, 1, 10, 10, 10, 2]
# Para sumar simplemente recorremos el arreglo y aumentamos el valor
suma = 0
for valor in arreglo:
suma = suma + valor
print(f"La suma es {suma}")
# Y el promedio se obtiene dividiendo la suma entre la cantidad de elementos
cantidad_elementos = len(arreglo)
promedio = suma / cantidad_elementos
print(f"El promedio es {promedio}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment