Answer the question
In order to leave comments, you need to log in
How to make a decision when translating systems of calculation?
How to make a complete solution in this code as in the screenshots? When converting from decimal to any other system, you need to divide, and if vice versa, then multiply.
def convert_base(num, to_base=10, from_base=10):
# first convert to decimal number
n = int(num, from_base) if isinstance(num, str) else num
# now convert decimal to 'to_base' base
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
res = ""
while n > 0:
n,m = divmod(n, to_base)
res += alphabet[m]
return res[::-1]
Answer the question
In order to leave comments, you need to log in
If you just need to display the "ladder", then you need to format the string and output it in the while loop, for example, increasing the indentation each loop.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question