Advertisement
Stosswalkinator

Reverse Guess the Number Python

Nov 20th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. __author__ = 'stosswalkinator'
  2.  
  3. # Reverse Guess the Number Game
  4. # Where the user chooses a number
  5. # and the computer tries to guess it
  6.  
  7. import random
  8. import time
  9.  
  10. print("Welcome to my Reverse Guess the Number game!")
  11. print("Where you choose the number and the computer will try and guess it!")
  12. print("Please enter your number between 1 and 100: ")
  13. userNum = int(input())
  14.  
  15. computerNum = 50
  16.  
  17. tries = 0
  18.  
  19. while tries < 100:
  20.     print(computerNum)
  21.     if computerNum > userNum:
  22.         print("That was too high!\n\n")
  23.         tries += 1
  24.         print(str(tries) + '\n\n')
  25.         highNum = random.randint(1, 50)
  26.  
  27.     elif computerNum < userNum:
  28.         print("That was too low!\n\n")
  29.         tries += 1
  30.         print(str(tries) + '\n\n')
  31.         lowNum = random.randint(50, 100)
  32.  
  33.     else:
  34.         print("Your number was " + str(userNum) + " !")
  35.         print("I guessed it in " + str(tries) + " tries!")
  36.         print(":)")
  37.  
  38.     computerNum = random.randint(1, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement