Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started