Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Number Guesser

a guest Apr 4th, 2020 234 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. lower_bound = 0
  2. upper_bound = 100
  3. guess = int((upper_bound + lower_bound) / 2)
  4. secret_number = ""
  5. answer = ""
  6.  
  7. print("Please think of a number between", lower_bound, "and", upper_bound)
  8. print("Is your secret number", guess, "?")
  9. while answer != "c":
  10.     answer = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly.")
  11.     if answer == "h":
  12.         upper_bound = guess
  13.         guess = int((upper_bound + lower_bound) / 2)
  14.         print("Is your secret number", guess, "?")
  15.     elif answer == "l":
  16.         lower_bound = guess
  17.         guess = int((upper_bound + lower_bound) / 2)
  18.         print("Is your secret number", guess, "?")
  19.     elif answer == "c":
  20.         print("Game over. Your secret number was:", guess)
  21.     else:
  22.         print("Sorry, I did not understand your input")
  23.         print("Is your secret number", guess, "?")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top