Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. x = int(input("Choose your secret number: "))
  2. low = 1
  3. ans = (low + x) / 2
  4. print("Is your secret number", ans ,"?")
  5. g = 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. ")
  6. while ord(g) != ord('c'):
  7.     if ord(g) == ord('l'):
  8.         high = ans / 2
  9.     elif ord(g) == ord('h'):
  10.         low = ans
  11.     print("Is your secret number", ans ,"?")
  12.     g = 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. ")
  13. print("Your secret number is", ans ,".")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement