# [Tutor] still need help..

Kent Johnson kent37 at tds.net
Thu Sep 27 04:07:19 CEST 2007

```Chris wrote:
>
> Here some more work:
>
>
> guess = 0
>
> Print ?Pick a number between 0 and 100?
>
>
> While guess != ________ :
> 	print ?My first guess is ?, guess
> 	print ?Is my guess correct??
> 	if guess = = type3
> 		print ?I got it!?
> 	if guess > _______:
> 		pick lower #
> 	if guess <_______ :
> 		pick higher #
>
> that?s all I can do right now?
>
> the mechanism that I can?t figure out is how to show in code form how the
> computer goes to the next guess using the split range... ie. if the first
> guess is 50, the second guess would be taken from the 50-100 (50/2 = 25 + 50
> = 75) second guess  would be 75 if the number is too high.  If the number
> falls below 50, then the split range is 25, ect?

What I would do is keep a variable delta that gets added to or
subtracted from the current guess, depending on whether the guess is too
high or too low. Each time through the loop, make delta smaller by
dividing by two unless delta is already down to 1.

Are you reading Python Programming for the absolute beginner? This
problem is exercise 4 for chapter 3 in my copy. Have you tried exercises
1-3? They are not so hard as this one.

Kent
```