import random
def main():
print "Welcome. \nSelect the way you want to play.\n1-Human Guesses \n2-Computer Guesses"
play()
def play():
typeOfGame= input("Which type of game do you want to play?:")
if typeOfGame==1:
humanGuesses()
elif typeOfGame==2:
computerGuesses()
else:
return "error"
def computerGuesses():
low = 1
high = 100
guess = random.randint(low,high)
print guess
turns = 1
choice = input("1-Too High\n2-Too Low\n3-Neither. You got it!\nAm I too high or too low?:")
while choice !=3:
if choice == 1:
high = guess
guess = random.randint(low, high - 1)
else:
low = guess
guess = random.randint(low+ 1,high)
print guess
choice = input("1-Too High\n2-Too Low\n3-Neither. You got it!\nAm I too high or too low?:")
turns +=1
print "I got it! It only too me", `turns`, "guesses. I'm so gangster."
def humanGuesses():
number= random.randint (1,100)
guess = input("My guess is:")
turns = 1
while guess != number:
if guess < number:
print "Too low, fool. Try again."
guess = input("My guess is:")
else:
print "Too high, fool. Try again."
guess = input("My guess is:")
turns +=1
print "You FINALLY got it, after", `turns`, "guesses. Lame."
main()