Question: Write a recursive Python function, to _binary, that takes an integer, N (where N 0), and returns a string representing the unsigned binary equivalent of
Write a recursive Python function, "to _binary", that takes an integer, N (where N 0), and returns a string representing the unsigned binary equivalent of N. Your function need only support positive (not negative or zero) numbers. Here are some example inputs and expected outputs: >>> to binary(1) >> to binary(9) 1001 >>> to.binary(254) Hint: The most natural way to implement this function is via the "divide-by-two" method of converting decimal to binary (that we introduced in class). Note: Your function should accept any integer, so the result could have any number of bits (i.e., the bit-width of the result is not fixed for all inputs). Note: Your function must be recursive to receive any credit for this bonus
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
