Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Guessing Game
- def function_middle(i, max, min):
- middle = int((max + min)/2)
- print("The middle of range is: ", middle) #to see middle of the range
- answer = input("Is your number [H]igher, [L]ower or the [S]ame as {}".format(middle)).upper()
- if answer == "S":
- print("Your number is {}, it took me {} guess".format(middle, i))
- quit()
- if answer == "H":
- min = middle
- elif answer == "L":
- max = middle
- print(i, max, min) #to see counter, max and min values of the range
- return i, max, min
- max = 101
- min = 0
- print("Think of a number between 1 and 100")
- for i in range (9):
- print(i) #counter
- i,max,min = function_middle(i, max, min)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement