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… -----Original Message----- From: bhaaluu [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 26, 2007 5:13 AM To: Chris Cc: tutor@python.org Subject: Re: [Tutor] python problem Greetings Chris, On 9/25/07, Chris <[EMAIL PROTECTED]> wrote: > > Ok as I see it, it's should go like this: > > Print 'Think of a number between 1 and 100, and let me guess it' > > Type1 = input ('Type 1 if I am high') > Type2 = input ('Type 2 if I am low') > Type3 = input ('Type 3 if I am dead on') > > I can't seem to get the guts of it. I assume that there are 3 if statements > and a while statement. > > guess > > While x != > If guess > > > > I get lost right around here...help! Thunk! er, Think! =) Play the guess-a-number game, and jot down exactly what YOU do to make a guess. Prompt:> Think of a number between 1 and 100. Got it? Prompt:> Okay, now I, the Great Computer, will guess the number... Prompt:> Is the number 51? Prompt:> 0=Correct, 1=Lower, 2=Higher: _ The range is 1 to 100. Let's say you think of the number 37. At he prompt, you type 1 because the number is Lower than 51. (or whatever scheme you decide to use.) If you were playing against the computer, and the computer told you to guess Lower, what would you do? Would you guess 50? 49? 10? 1? How do you guess when you're playing the game? How do you narrow it down? Figure it out. So, now you think you can outsmart the computer half-way through the game by thinking of a different number, say 38.... Pretty sneaky! That's like palming the pea in a shell game. Granted, the Great Computer, isn't very smart... but it IS an idiot savant. It can remember tons of information that you've forgotten as irrelevant just seconds ago. So what the Great Computer has been doing, while guessing, is keeping track of the bounds it can guess between, from the hints you've been providing [0,1,2, whatever] and maybe even a list of all its guesses that were not correct. And in a split second, it can compare all that stuff. Chris, what constraints are you working under? How many Python 'tools' (keywords, methods, etc.) do you have to solve the problem with? Input? [raw_inpu(), input(), ...], Output? [print, ...], Selection? [if, elif, else, ...] Iteration? [for, while, ...]. You also have to consider what you have to work with so far. -- b h a a l u u at g m a i l dot c o m http://www.geocities.com/ek.bhaaluu/index.html No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.487 / Virus Database: 269.13.25/1018 - Release Date: 9/19/2007 3:59 PM
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor