Skip to content

Instantly share code, notes, and snippets.

@alphanetEX
Created May 5, 2020 01:07
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 alphanetEX/5b4bea07ea2993a699651c82ee9c5d7c to your computer and use it in GitHub Desktop.
Save alphanetEX/5b4bea07ea2993a699651c82ee9c5d7c to your computer and use it in GitHub Desktop.
Dado el siguiente array: numeros = [15, 74,110,9,8,1,0,14,78,13,150,4] Mostrar la suma de todos los elementos pares contenidos en el arreglo.
def pair():
numbers = [15,74,110,9,8,1,0,14,78,13,150,4]
counter = 0
acumulator = 0
while counter <= len(numbers) -1:
if numbers[counter] % 2 == 0:
acumulator += numbers[counter]
counter += +1
return str(acumulator)
print("la suma de los elemtos pares es de :", pair())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment