[Tutor] python problem

Chris balderas at whtvcable.com
Wed Sep 26 04:16:35 CEST 2007

Ok, in this case the guessing game is design to guess the number (0-100)
that the user holds in his head.

I assume that Python off the bat Python gives a first guess.


I guess 50  #(using the split range)
Depending on the user # Python asks:

Press 1 if I am high.
Press 2 if I am low.
Press 3 if I got it.

Throughout the guessing Python should use the split range method. Python
should also be able to tell the user if he or she is cheating....and you
wonder why I need help...yikes!

Pseudo code:

Guess the number from the user using 1,2,3 keys
	Ask the user if # is high, low, or dead on.
		Print 'you got it' when Python gets it.

As you can see I need help. I've given you the pseudo code.


-----Original Message-----
From: bhaaluu [mailto:bhaaluu at gmail.com] 
Sent: Tuesday, September 25, 2007 4:37 AM
To: Chris
Cc: tutor at python.org
Subject: Re: [Tutor] python problem

On 9/25/07, Chris <balderas at whtvcable.com> wrote:
> I have this GUESSING GAME code found below:
> ---------------------
> import random
> number = random.randint(1, 101)
> print "I've thought of a number between 1 and 100."
> print "Try and guess it!"
> print
> guess = input( "What's your guess? ")
> while guess != number:
>     if guess > number:
>         print "Your guess is too high."
>     else: #elif guess < number:
>         print "Your guess is too low."
>     guess = input( "What's your next guess? " )
> print "Congratulations! You guessed the number."
> ----------------------------------------------------
> What do I have to do to the code so that the Guessing Game that tries to
> guess a number the user has thought of. (Make sure it can tell if the user
> tries to cheat, e.g. by changing the number during the game??
> I hope you can help!

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

More information about the Tutor mailing list