Skip to content

Instantly share code, notes, and snippets.

@lrlucena
Created April 2, 2018 11:59
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 lrlucena/b15a34e0a128847c51b9f910cae46954 to your computer and use it in GitHub Desktop.
Save lrlucena/b15a34e0a128847c51b9f910cae46954 to your computer and use it in GitHub Desktop.
Aulas While
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)
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)
# 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