anonymous
  • anonymous
def jumpAndBackpedal(isMyNumber): ''' isMyNumber: Procedure that hides a secret number. It takes as a parameter one number and returns: * -1 if the number is less than the secret number * 0 if the number is equal to the secret number * 1 if the number is greater than the secret number returns: integer, the secret number ''' Pls correct the code such that it only return the secret number
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
It is a Python code.
anonymous
  • anonymous
It is not exactly clear what is intended here but here is some code that you should be able to adapt to do what you need. It tries to guess the number in num that is between 0 and 100. import random num = random.randrange(101) def secretNum(guess): if guess < num: return -1 elif guess == num: return 0 else: return 1 def jumpAndBackpedal(isMyNumber): min_guess = 0 max_guess = 100 done = False while not done: guess = (max_guess + min_guess) // 2 print(max_guess, min_guess, guess) res = isMyNumber(guess) if res == -1: min_guess = guess elif res == 1: max_guess = guess else: done = True return guess print("Secret Number was:", jumpAndBackpedal(secretNum))

Looking for something else?

Not the answer you are looking for? Search for more explanations.