Created
October 22, 2021 19:37
-
-
Save guidani/2586b3d1019140b3da385914e9dcf695 to your computer and use it in GitHub Desktop.
jogo de adivinhação
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 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