Last active
April 12, 2017 21:57
-
-
Save MendesGabriel/9dc0a338db18d933893ca2b89feb00f8 to your computer and use it in GitHub Desktop.
Faça um algoritmo que calcule a média simples de números pares. Deve-se ler números até que seja informado um número negativo.
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
''' | |
Faça um algoritmo que calcule a média simples de números pares. | |
Deve-se ler números até que seja informado um número negativo. | |
''' | |
n = 0 | |
soma = 0 | |
contador = 0 | |
while n >= 0: | |
n = int(input('n: ')) | |
if n % 2 == 0 and n > 0: | |
soma = soma + n | |
contador += 1 | |
media = soma / contador | |
print('media: ', media) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment