Aulas While
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
import random | |
numero = random.randint(1, 100) | |
print("Escolhi um numero entre 1 e 1000.") | |
print("Tente descobrir.") | |
palpite = int(input("Qual o seu palpite?")) | |
contador = 1 | |
while palpite != numero: | |
if numero > palpite: | |
print("O numero é maior do que", palpite) | |
else: | |
print("O numero é menor do que", palpite) | |
palpite = int(input("Qual o seu palpite?")) | |
contador = contador + 1 | |
print("Parabens, você acertou em %d vezes!!" % contador) |
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
soma = 0 | |
cont = 0 | |
nota = float(input()) | |
while nota >= 0: | |
soma = soma + nota | |
cont = cont + 1 | |
nota = float(input("Digite a nota:")) | |
media = soma / cont | |
print("Media = %.1f" % media) |
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
# Repita n vezes: Somar 2 numeros | |
ficha = 5 | |
while ficha > 0: | |
a = int(input()) | |
b = int(input()) | |
c = a + b | |
print(c) | |
ficha = ficha - 1 | |
print("FIM") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment