Advertisement
superpawko

Untitled

Sep 28th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. low = 0
  2. high = 100
  3. epsilon=1
  4. ans = (high - low) // 2
  5. check=''
  6. number=input("Please think of a number between 0 and 100!")
  7.  
  8. while ans > epsilon:
  9. print("Is your secret number " + str(ans) + "?")
  10. check = 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 check == 'c':
  12. print("Game over. Your secret number was:" + str(ans))
  13. break
  14. elif check == 'h':
  15. high = ans
  16. elif check == 'l':
  17. low = ans
  18. else:
  19. print("Sorry, I did not understand your input.")
  20. print("L: ", low, end= "")
  21. print(" H: ", high, end= "")
  22. ans = (high + low) // 2
  23. print(" mid: ", ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement