1. # Number guessing game.
  2. # The computer plays itself, if the number is too high or too low the player is informed.
  3. # If the game takes longer than 10 rounds, it is an automatic lose.
  4.  
  5. import random
  6. random.seed
  7.  
  8. CompGuess =  random.randint(1,100)
  9. CompPlayer = random.randint(1,100)
  10. print "CompPlayer\'s secret number is " +str(CompPlayer)
  11. LowInt1 = 1
  12. HighInt1 = 100
  13. RoundCount = 1
  14. running = True
  15. while running == True:
  16.     print "Round Number : " +str(RoundCount)
  17.     if RoundCount == 11:
  18.         print "CompPlayer: You took too long, you lose!"
  19.         running = False
  20.     print "CompGuesser: My guess is " +str(CompGuess)
  21.  
  22.     if CompGuess > CompPlayer:
  23.         print 'CompPlayer: Your guess is high'
  24.         HighInt1 = CompGuess
  25.         CompGuess = random.randint(LowInt1, HighInt1)
  26.         print "Range is " +str(LowInt1)+ ' , ' +str(HighInt1)
  27.         print CompGuess
  28.     if CompGuess < CompPlayer:
  29.         print 'CompPlayer: Your guess is low'
  30.         LowInt1 = CompGuess
  31.         CompGuess = random.randint(LowInt1, HighInt1)
  32.         print "Range is " +str(LowInt1)+ ' , ' +str(HighInt1)
  33.         print CompGuess
  34.     if CompGuess == CompPlayer:
  35.         print "CompGuesser: I win! :3"
  36.         running = False
  37.     RoundCount = RoundCount + 1