Question ( see uploaded pic ): Given Code (Python): def binary_to_decimal_1(str, n): #Base Case/s #Add conditions here for base case/s if True : print("I will be printed before this recursive function...


Question (
see uploaded pic
):



Given Code (Python):


def binary_to_decimal_1(str, n):
    #Base Case/s
    #Add conditions here for base case/s
    if True :
        print("I will be printed before this recursive function ends.")
        return 0


    #Recursive Case/s
    #Add conditions here for recursive case/s
    else:
        return binary_to_decimal_1(str, n)


def binary_to_decimal_2(str):
    #Base Case/s
    #Add conditions here for base case/s
    if True :
        print("I will be printed before this recursive function ends.")
        return 0


    #Recursive Case/s
    #Add conditions here for recursive case/s
    else:
        return binary_to_decimal_2(str)


#Handle binary string input.

binary_string = input("Please enter a binary string: ")
print(binary_string)


#Do function calls and print return values.


The code is already given above.<br>Problem: Using PYTHON, create a code that asks you to enter a binary string and you must use this binary string as<br>an input to your functions. These functions will be recursive functions that return the decimal number equivalent of your<br>binary string input.<br>Example (Input):<br>Example (Input #2):<br>1111<br>0000<br>Example (Output):<br>Example (Output #2):<br>Please enter a binary string: 1111<br>Calculating the decimal number equivalent using implementation 2.<br>The decimal number equivalent of 1111 is 15.<br>Please enter a binary string: 0000<br>Calculating the decimal number equivalent using implementation 1.<br>The decimal number equivalent of 0000 is 0.<br>Implementation 1: A recursive function with two inputs: a binary string, and a number. You can think of this as the index<br>that allows you to access each element in your sequence.<br>Implementation 2: A recursive function with only one input: the binary string.<br>Constraints: Do implementation 1 if the binary string starts with a '0'. Otherwise, do implementation 2 if the binary string<br>starts with '1'. Before you return a value in your recursive function's base case, print a statement that reveals the identity<br>of the function that is currently used.<br>

Extracted text: The code is already given above. Problem: Using PYTHON, create a code that asks you to enter a binary string and you must use this binary string as an input to your functions. These functions will be recursive functions that return the decimal number equivalent of your binary string input. Example (Input): Example (Input #2): 1111 0000 Example (Output): Example (Output #2): Please enter a binary string: 1111 Calculating the decimal number equivalent using implementation 2. The decimal number equivalent of 1111 is 15. Please enter a binary string: 0000 Calculating the decimal number equivalent using implementation 1. The decimal number equivalent of 0000 is 0. Implementation 1: A recursive function with two inputs: a binary string, and a number. You can think of this as the index that allows you to access each element in your sequence. Implementation 2: A recursive function with only one input: the binary string. Constraints: Do implementation 1 if the binary string starts with a '0'. Otherwise, do implementation 2 if the binary string starts with '1'. Before you return a value in your recursive function's base case, print a statement that reveals the identity of the function that is currently used.
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here