Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Program where the computer guesses a number between 1 and 100
- # The user tells the computer if it guesses too high or too low.
- import random
- random.seed
- CompGuess = random.randint(1,100)
- print "Pick a number."
- LowInt1 = 1
- HighInt1 = 100
- running = True
- while running == True:
- print CompGuess
- UserResp = raw_input("Was I right? H/L/Y: ")
- if UserResp == "H":
- HighInt1 = CompGuess
- CompGuess = random.randint(LowInt1, HighInt1)
- print CompGuess
- if UserResp == "L":
- LowInt1 = CompGuess
- CompGuess = random.randint(LowInt1, HighInt1)
- print CompGuess
- if UserResp == "Y":
- print "Hurrah! :3"
- running = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement