Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 9th, 2012  |  syntax: None  |  size: 0.39 KB  |  views: 56  |  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. #guessing game, user picks #, computer guesses
  2. guess = 50
  3. low = 1
  4. high = 100
  5. answer = ""
  6. while answer != "y":
  7.     answer = raw_input("Is your number %s? (Yes,Higher,Lower)" % guess)
  8.     if answer == "h":
  9.         low = guess
  10.         guess = (guess + high)/2
  11.     if answer == "l":
  12.         high = guess
  13.         guess = (guess + low)/2
  14.     if answer == "y":
  15.         print "i won!"
clone this paste RAW Paste Data