# # a simple guessing game that uses Python's random # number generator to come up with a number to be # guessed by the user. # # written by e.bonakdarian oct 12, 2010 # "get/make accessible" the random number generator from random import randint # set lower and upper bounds on the number to be guessed # see how this propagates throughout the code LOW = 0 HIGH = 10 def main(): target = randint(LOW, HIGH) # number to be guessed guess = input('Enter a number in range %d - %d: ' %(LOW, HIGH)) # get user's guess print 'target is %d.' % target # display correct number if guess == target: print 'You win!' else: print 'You lost :-)' main()