Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. # Guess The Number
  2.  
  3. import random
  4.  
  5. print("I'm thinking of a number between 1 and 100.  What is it?")
  6.  
  7. #initial values
  8. the_number = random.randint(1, 100)
  9. guess = int(input("Take a guess: "))
  10. tries = 1
  11.  
  12. while guess != the_number:
  13.     if guess > the_number:
  14.         print("Lower. ")
  15.     else:
  16.         print("Higher. ")
  17.     guess = int(input("Take a guess: "))
  18.     tries += 1
  19.  
  20. print("Correct!  The number was", the_number)
  21. print("It only took you", tries, "tries!")
  22.  
  23. input("\n\nPress the enter key to exit.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement