Skip to content

Instantly share code, notes, and snippets.

@guidani
Created October 22, 2021 19:37
Show Gist options
  • Save guidani/2586b3d1019140b3da385914e9dcf695 to your computer and use it in GitHub Desktop.
Save guidani/2586b3d1019140b3da385914e9dcf695 to your computer and use it in GitHub Desktop.
jogo de adivinhação
def main():
rodada = 1
while rodada <= TOTAL_TENTATIVAS:
print('-' * 30)
print(f"Tentativa {rodada} de {TOTAL_TENTATIVAS}!")
chute = int(input('Numero: '))
print('Você digitou: ', chute)
valor = compara_numeros(NUMERO_SECRETO, chute)
print('você acertou' if valor else 'você errou')
if valor:
break
else:
maior_menor(chute, NUMERO_SECRETO)
rodada += 1
def compara_numeros(n1, n2):
if n1 == n2:
return True
return False
def maior_menor(usuario, sistema):
if usuario > sistema:
print('Seu numero é maior!')
else:
print('Seu número é menor!')
if __name__ == '__main__':
print('******************************')
print('*Jogo da adivinhação*')
print('******************************')
NUMERO_SECRETO = 42
TOTAL_TENTATIVAS = 3
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment