On Mar 2, 2014, at 12:43 AM, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
> 
> No, that's the opposite direction :-) Inside the ‘get_guess’ function
> you should use as many names as you need for the different purposes.
> 
> So, you have one name ‘guess_number’ bound to the function's parameter.
> Don't bind anything else to it!
> 
> Then, for the return value from ‘raw_input’, you should choose a
> different suitable name and bind that name to the value (with an
> assignment statement).
> 
> Then, for the computed result, you should choose yet another suitable
> name, and bind *that* name to the computed value.
> 
> All these different names will make clear in the code what the meaning
> of each value is.
> 
Ok, I see.  So, I think I got a good portion of this done thanks to you guys 
and understanding the directions a little better.  I’ll post my code.  For some 
reason I’m not sure what the user_guess variable in the get_guess is actually 
doing, or if it’s even an appropriate variable name??  Also, I’m going to bold 
another part I’m struggling with about the number being out of range, I’m not 
sure I’m going in the right direction with that, mainly because it does not 
work.  Here is what I have so far…


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):
    if guess < 0 or guess> 101:
        print "Out of range!"

def main():
    print_description()
    secret = randrange(1,101)
    current_guess = get_guess(1)

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

main()
print_hints()
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to