[Python] Guess your number 02-09-2013, 02:18 PM
#1
I wrote this a while ago and forgot all about it if I'm honest, Deque reminded me with her competition here. it's nothing special you think of a number and the program guesses it and prints out how many tries it took
Code:
# Guess your number
# Player thinks of a number between 1 and 100 and the computer tries to guess it
import random
print "Think of a number between 1 and 100."
print "And I will try to guess it."
tries = 0
guess = ""
high = 100
low = 1
while guess != "c":
number = random.randrange(low, high)
print "I think of: ", number
guess = raw_input("[h]iger, [l]ower, [c]orrect: ")
if guess == "h":
low = number +1
tries += 1
if guess == "l":
high = number -1
tries += 1
print "I got it in ", tries, "go's!"
raw_input("\n\nPress the enter key to exit.")
If you need help feel free to PM me
![[Image: klfpJD]](http://goo.gl/klfpJD)
Probitcoin
Freebitcoin
BTC clicks
bitcoin wallet:
1FBPAanbs3rJU9BUpobpDJc9hHUaCaC25N
Probitcoin
Freebitcoin
BTC clicks
bitcoin wallet:
1FBPAanbs3rJU9BUpobpDJc9hHUaCaC25N