Question: PYTHON 3, SIMPLE ONE RECURSIVE FUNCTION In a file named base_convert.py, write a recursive function named convert(num. b) that will take a non-negative integer num
PYTHON 3, SIMPLE ONE RECURSIVE FUNCTION
In a file named base_convert.py, write a recursive function named convert(num. b) that will take a non-negative integer num (base 10) and a base b (integer from 2 to 16) and return a string representing the base b number:
def convert(num, b): """Recursive function that returns a string representing num in the base b"""
convert(30,4) returns "132"
convert(45,2)) returns "101101"
convert(316,16) returns "13C"
For bases > 10, the symbols used for 10, 11, 12, 13, 14, 15 are A, B, C, D, E, F respectively
RETURN 0 if num is 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
