Last active
September 17, 2015 16:08
-
-
Save williamd1k0/de00741fc6cfcc1f020d to your computer and use it in GitHub Desktop.
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
| # -*- coding: UTF-8 -*- | |
| import random | |
| robotNumber = random.randint(1,100) | |
| tentativas = 1 | |
| yourNumber = "" | |
| #print robotNumber | |
| print u"\n Estou pensando em um número entre 1 e 100!\n Tente advinhar qual é!" | |
| while yourNumber == "": | |
| try: | |
| yourNumber = int(raw_input("> ")) | |
| except: | |
| print u" Isso nem ao menos é um número!" | |
| yourNumber = "" | |
| print u" Tente mais uma vez!" | |
| while yourNumber != robotNumber: | |
| if yourNumber < robotNumber: | |
| print u" O número %s é menor do que estou pensando!" %yourNumber | |
| else: | |
| print u" O número %s é maior do que estou pensando!" %yourNumber | |
| tentativas += 1 | |
| yourNumber = "" | |
| while yourNumber == "": | |
| try: | |
| yourNumber = int(raw_input("> ")) | |
| except: | |
| print u" Isso nem ao menos é um número!" | |
| yourNumber = "" | |
| print u" Tente mais uma vez!" | |
| else: | |
| print u" Parabéns, o número era %s mesmo!" %robotNumber | |
| print u" Você usou %s tentativas." %tentativas | |
| raw_input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment