Hey all once again how would you create a function called
. Inside the function, implement an algorithm to convert decimal numbers between
to their binary equivalents.
For any invalid input, return string Invalid input
Example: For number 5 return string
i may have found a possible solution
1 |
binary_converter |
1 |
0 and 255 |
For any invalid input, return string Invalid input
Example: For number 5 return string
1 |
101 |
i may have found a possible solution
1 2 3 4 5 6 7 8 9 10 11 |
def convertToBinary(n): """Function to print binary number for the input decimal using recursion""" if n > 1 : convertToBinary(n / / 2 ) print (n % 2 ,end = '') # decimal number dec = 34 convertToBinary(dec) |