# Help with "Guess the number" script

Scott W Dunning swdunning at cox.net
Mon Mar 3 04:44:47 CET 2014

```On Mar 2, 2014, at 6:40 PM, Scott W Dunning <swdunning at cox.net> wrote:

This is what Im having trouble with now.  Here are the directions I’m stuck on and what I have so far, I’ll bold the part that’s dealing with the instructions if anyone could help me figure out where I’m going wrong.

Thanks!

from random import randrange
randrange(1, 101)
from random import seed
seed(129)

def print_description():
print """Welcome to Guess the Number.
I have seleted a secret number in the range 1 ... 100.
You must guess the number within 10 tries.
I will tell you if you ar high or low, and
I will tell you if you are hot or cold.\n"""

def get_guess(guess_number):
promt = "(" + str(guess_number) +") Please enter a guess:"
user_guess = raw_input(promt)
user_guess = int(user_guess)
return user_guess

def print_hints(secrets, guess):
secret_number = secret
guess = guess
if guess < 0 or user_guess> 101:
print "Out of range!"

def main():
print_description()
secret = randrange(1,101)
current_guess = get_guess(1)
if current_guess != secret:
print_hints(secret_number, guess)
current_guess = get_guess(2)

if secret == current_guess:
print "Congratulations, you win!"
else:
print "The secret number was", secret

main()
Just below the body of the get guess function, define a new function named print hints that takes two arguments. The first is a secret num- ber and is kept in a parameter named secret. The second is a guess made by the user and it is held in a parameter named guess.

The user’s guess is supposed to be within the range 1 ... 100. Write a conditional statement that checks if the guess is out of that range, and if it is print ‘out of range’ in the body of the print hints function.

Now we are going to give the user the option to make a second guess. You must add code to the main function immediately after assignment statement you wrote for task 7.

Write a conditional statement to check if the current guess does not match the secret number. If the numbers to not match, in the body of the conditional statement you will do two things.

(a)  call print hints to give the user hints,

(b)  re-assign current guess to the result of calling get guess with an

argument of 2.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140302/777dae00/attachment.html>
```