python
Answer the following question without running the code. The procedure isMyNumber is used to hide a secret number (integer). It takes an integer x as a parameter and compares it to the secret number. It returns:
-1 if the parameter x is less than the secret number
0 if the parameter x is correct
1 if the parameter x is greater than the secret number
The following procedure, jumpAndBackPedal, attempts to guess a secret number. The only way it can interact with the secret number is through the isMyNumber procedure explained above.
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
'''
guess = 1
if isMyNumber(guess) == 1:
return guess
foundNumber = False
while not foundNumber:
sign = isMyNumber(guess)
if sign == -1:
guess *= 2
else:
guess -= 1
return guess
Unfortunately, the implementation given does not correctly return the secret number. Please fix the errors in the code such that jumpAndBackpedal correctly returns the secret number.
Code Starts from here
___________________________________________________________________________
def isMyNumber(x):
secret_number =199;
if x ==secret_number:
return 0
if x > secret_number:
return 1
else:
return -1
def jumpAndBackpedal(Number):
#Change the jumpAndBackpedal Functions parameter name because it was creating error.
#"TypeError 'int' object is not callable" It probably means that you are trying to call a method when a property with the
# same name is available. If this is indeed the problem, the solution is piece of Cake..
guess = 1
while True:
if isMyNumber(guess) == 0:
break
else:
if isMyNumber(guess) == 1:
guess=guess-1
if isMyNumber(guess) == -1:
guess=guess+1
return guess
jumpAndBackpedal(5)
____________________________________________________________________________
Code is over and i am attaching the problem screenshot



python Answer the following question without running the code. The procedure isMyNumber is used to hide...