##Due: Monday
##---
##
##Submit online : GuessingGame
##--------------
##
##
##Assignment:
##----------
##
## Make a program where the user can play the guessing
## game against the computer in the following two ways:
##
## 1. The computer prompts the user to guess a number
## from say 1 to 100, and reduces the range of vales
## until the user guesses the correct value. The
## program should print the number of guesses taken.
## For example, say the number to guess is 15, a sample
## run may look like this.
## Enter a # from 1 to 100: 54
## Enter a # from 1 to 54: 8
## Enter a # from 8 to 54: 15
## You're correct! That took 3 guesses.
##
## 2. In this version, the computer makes guesses while
## the human provides feedback. For example, the human
## chooses 33, a sample run may look like this.
##
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)
else:
low = guess
guess = random.randint(low,high)
print guess
turns +=1
return "I got it! It only too me", `turns`, "guesses. I'm so gangster."
main()