All pastes #2069321 Raw Edit

Something

public python v1 · immutable
#2069321 ·published 2011-05-26 07:57 UTC
rendered paste body
#!/usr/bin/python2.7import randomrnd = random.Random()def playGame(limit=100):    print "I'm thinking of a number between 1 and %d..." % (limit)    num = rnd.randint(1, limit + 1)    guess = -1    cnt = 0    while num != guess:        guess = raw_input("Your guess? ")        if not guess.isdigit():            continue        guess = int(guess)        cnt += 1        if guess > num:            print "It's lower."        elif guess < num:            print "It's higher."    print "You guessed it in %d guesses!" % (cnt)    return cntagain = Truetotal_tries = 0games = 0best_game = 0print """This is a poem.I don't know haikus.Watermelon."""printwhile again:    tries = playGame()    total_tries += tries    games += 1    if best_game > tries:        best_game = tries    again = raw_input("Play again? ").startswith('y')printprint "Your overall results:"print "Total games    = %d" % gamesprint "Total guesses  = %d" % total_triesprint "Guesses/game   = %d" % (float(total_tries))/gamesprint "Best game      = %d" % best_game