Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- low = 0
- high = 100
- epsilon=1
- ans = (high - low) // 2
- check=''
- number=input("Please think of a number between 0 and 100!")
- while ans > epsilon:
- print("Is your secret number " + str(ans) + "?")
- 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.")
- if check == 'c':
- print("Game over. Your secret number was:" + str(ans))
- break
- elif check == 'h':
- high = ans
- elif check == 'l':
- low = ans
- else:
- print("Sorry, I did not understand your input.")
- print("L: ", low, end= "")
- print(" H: ", high, end= "")
- ans = (high + low) // 2
- print(" mid: ", ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement