Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Computer Number Guessing Game

By: a guest on May 10th, 2012  |  syntax: Python  |  size: 1.15 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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