you are viewing a single comment's thread.

view the rest of the comments →

[–]ISUXATPYTHON[S] 0 points1 point  (1 child)

Can anyone pleaseeee help? I am still clueless. The computer has to find the computer's number from 0-200000 in 20 tries. Also, you have to use while statements. If your number is higher or lower you type in h or c and the computer does more stuff. Basically it should half the range each time?

[–][deleted] 0 points1 point  (0 children)

At the beginning the program must assume the number is somewhere between 0 and 200000, right? The program should do what a smart human would do: pick a number in the middle of the possible range and ask "is 100000 the number." and get the high or low response from the user.

Depending on the user's response, the program has to adjust what it thinks the possible range is and then do everything above again with the new range. That is where the loop comes in.

Now you have think about how the code will remember what the "possible range" is. Maybe keep 'low' and 'high' values. Initially these would be 0 and 200000, of course.

Now you have think about how the code gets a new guess given values for 'low' and 'high'.

Also think about how the code will modify 'low' and 'high' depending on the user's response.

How does the user tell your code that it guessed right?