Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. from random import *
  2.  
  3. print('**************')
  4. print('Joguim de adivinha numeral')
  5. print('**************')
  6.  
  7. tentativas = 5
  8. chute = 0
  9. numero = randrange(30)
  10.  
  11. while tentativas > 0:
  12. chute = int(input('Digite um chute\n'))
  13.  
  14. print('Você tentou:\n', chute)
  15.  
  16. acerto = numero == chute
  17. maior = numero > chute
  18. menor = numero < chute
  19.  
  20. if(acerto):
  21. print("parabéns, você acertou!", numero)
  22.  
  23. else:
  24. tentativas = tentativas - 1
  25. if(maior):
  26. print("o número é maior\n")
  27.  
  28. if(menor):
  29. print("o número é menor\n")
  30. print('restam:', tentativas)
  31. if tentativas == 0:
  32. print("Você perdeu")
  33. print("O número era:", numero)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement