Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Number guesser

View gist:1806675
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/env python
 
lower, upper = 1, 100
 
print "Guess a number between %s and %s (inclusive)." % (lower, upper)
 
while lower < upper:
mid = (lower + upper) / 2
guess = raw_input("Is your number higher than %s? (y/n): " % (mid))
if guess == 'y':
lower = mid + 1
else:
upper = mid
 
print "Your number is %s!" % (lower)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.