Created
May 5, 2020 01:07
-
-
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.
This file contains hidden or 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
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