In general, converting a number in base b1≠ 10 to another base b2≠ 10 involves two steps: base b1 to base 10, and then base 10 to base b2. (Although there exist shortcuts when converting between binary and octal, and binary and hexadecimal, we won’t use them here.) There is a stub function translate_base(n, b1, b2) in the script file that, when completed, will operate according to the following specification:

The parameter n is a string representing a number in base b1. You may assume that n will always represent a valid number in base b1. The bases b1 and b2 are integers in the range 2 through 36 (inclusive)

The output of the function is a string representing the equivalent value in base b2

Your task has two parts:

The first task is to define four test cases you could use to check that translate_base works correctly for valid inputs, each annotated with a brief # comment on the line before saying why you created it. Each test case will be recorded as a 4-tuple composed of the arguments (parameter values) for translate_base (n, b1 and b2) and a string representing the expected result. There is a list named translate_base_test_cases declared in the assignment script that you need to modify to contain your four test cases. It already contains one test case, that you must replace, and the others all contain Nones, which you need to replace with valid values:

(’23’, 10, 10, ’23’)

which represents calling translate_base(’23’, 10, 10) and expecting the result to be ’23’ (yes, in this ‘test’ we are expecting it to convert from base 10 to base 10, so the result should be the same as the input).

You must define four different test cases. You may specify any (valid) inputs you wish, as long as b1 ≠ b2 in at least three of the cases, you do not repeat any particular combination of b1 (original base) and b2 (destination base) values, and none of your test cases uses b1 = b2 = 10 (as in the example). The last entry in each tuple must be the correct result for that particular conversion, even if your implementation of translate_base doesn’t work (i.e., you can get full marks for this part of the question even if you don’t attempt part (b).

The second task is to complete the implementation of translate_base(n, b1, b2) according to the specification above and with the following additional constraints:

You may define an additional function to perform one of the steps. That function may be your own creation, or come from the lecture slides or tutorial solutions

For a solution to receive full marks the body of translate_base must be one line of code (and not merely an alias for another, longer function). Anything longer will receive a maximum of 1/1.5

Script file is

#%% Question 6: translate_base

import string

digits = string.digits + string.ascii_uppercase

# Q6a: Record your FOUR test cases here. Remember to replace the example one provided.

translate_base_test_cases = [

# For each test case briefly (one line only) explain why you chose it/what it’s testing

(’23’, 10, 10, ’23’),

# Explanation of next test case…

(None, None, None, None),

# Explanation…

(None, None, None, None),

# Explanation…

(None, None, None, None)

]

# Q6b: Implement your solution

#Declare any additional helper function here

def translate_base(n: str, b1: int, b2: int) -> str:

”’

Converts n, a string representing a number in base b1, to a

string representing the same value in base b2. 2 <= b1, b2 <= 36.
'''
return None