Hello I am writing a project about binary searchs and was wondering if it were doable to create a binary search trying to the guess the number in the user's head. No number is typed in the computer rather the computer guesses. Any direction would be greatly appreciated.
from random import randint
print('Hello! What is your name?')
myname = input()
print('Well', myname, ', I want you to think of number in your head I will guess it.')
print("------------------------------------------------------------------------------")
print("RULES: if the number is correct simply input '='")
print("------------------------------------------------------------------------------")
print("if YOUR number is GREATER then the output, input '>'")
print("------------------------------------------------------------------------------")
print("if YOUR number is LESS then the output, input '<'")
print("------------------------------------------------------------------------------")
print("ALRIGHT LETS PLAY")
print("------------------------------------------------------------------------------")
def guessinggame(userinput):
STOP = '='
a = '>'
b = '<'
lowest_number = 1
highest_number = 100
guess = randint(1,100)
while True:
STOP = '='
a = '>'
b = '<'
lowest_number = 1
highest_number = 100
guess = (lowest_number+highest_number)//2
print("My First guess is", guess)
user_guess = input("is this greater,less than, or equal:")
if user_guess == STOP:
print("Test")
if user_guess is a:
low = guess + 1
print("hehehe")
elif user_guess is b:
high = guess
print("this is sorta working")
Any guidance or direction would be greatly appreciated.
Thank you
Aucun commentaire:
Enregistrer un commentaire