[Tutor] Help with Guess the number script

Alan Gauld alan.gauld at btinternet.com
Fri Mar 7 19:02:00 CET 2014


On 07/03/14 05:30, Scott W Dunning wrote:
> I am trying to write a script for class for a game called guess the number.

Others have given general hints here are a couple of specifics...

> def print_hints(secret, guess):
>      if guess < 1 or guess > 101:

As I recall the spec said guesses could be between 1 and 100?
What happens above if the guess is 101?

>      elif guess < (secret - 10) or guess > (secret - 10):

Do you really mean to test for secret minus 10 in both
expressions?

>      elif guess < (secret - 5) or guess > (secret - 5):
>          print "You are warmer!"

And similarly here, do you really want to test
against (secret-5) in both cases?

>      elif guess < (secret - 10) or guess > (secret - 10):
>          print "You are cold!"

And again...

>      elif guess < (secret - 5)or guess > (secret - 5):
>          print "You are warmer!"

And again...

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list