Question: Write an interactive program that prompts the user to think of an integer between one and a thousand and then asks the user to truthfully

Write an interactive program that prompts the user to think of an integer between one and a thousand and then asks the user to truthfully respond with true or false to statements of the form My number is less than or equal to x? for various values of x, until the program can deduce the chosen integer. Your program should use a strategy known as binary search for guessing. Binary search chooses the middle of the search interval as the value of x at every iteration. The Python function input() may be used to get input from the user while the program is running.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!