[Tutor] High Low Game
Raquel
raquel.adams at gmail.com
Tue Oct 19 00:34:19 CEST 2010
Hi,
I am new to Python, and have hit a WALL. Any help is appreciated! Below
is what I have so far, for the "High Low Game"...when I try to run it,
nothing happens, so I have been unable to finish it. I am sure it is
something simple...
#assignment 2 part 1 high low
def main():
print " Pick a number between 1 and 1000 and I will try to guess it"
print "in no more than 10 tries. After each guess, enter 0 if I"
print "got it right, -1 if I need to guess lower, and 1 if I need to"
print "guess higher."
high=1000
low=1
tries=1
while high > low:
ave=(high+low)/2
print "My guess is", ave,
guess=int(raw_input("Please enter '-1','0',or '1'):"))
print guess
if guess == 0:
print "That took 1", tries, "guesses."
elif guess == -1:
print "I will guess lower."
elif guess == 1:
print "I will guess higher."
else:
print "Pick a number between 1 and 1000 and I will try to guess
it"
print "in no more than 10 tries. After each guess, enter 0 if I"
print "got it right, -1 if I need to guess lower, and 1 if I need
to"
print "guess higher."
main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101018/17e08bc0/attachment.html>
More information about the Tutor
mailing list