Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- min = 1
- max = 1000000
- def guessing(min, max):
- while True:
- guess = random.randint(min,max)
- answer = input(str(guess)+'?(yes/no) ')
- answer = answer.lower()
- if answer == 'yes':
- break
- return guess
- def accuracy(answer, guess, min, max):
- if answer == 'no':
- accur = input('?(+/-) ')
- if accur == '+':
- min = guess, max = max
- guess = int(min+((max-min)/2))
- elif accur == '-':
- max = guess
- guess = int((min+(max-min)/2))
- else:
- while True:
- repeat_answer = input('wha? ')
- repeat_answer = repeat_answer.lower()
- if repeat_answer == 'yes' or repeat_answer == 'no':
- break
- else:
- continue
- return
- return accuracy()
- guessing(min,max)
- input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement