You are viewing a single comment's thread. Return to all comments →
def print_formatted(n): # your code goes here
x = None lista = [] max_longitud = len(bin(n).lstrip("0b")) # print(max_longitud) for i in range(1,n+1): hexadecimal = hex(i).lstrip("0x").rjust(max_longitud).upper() octadecimal = oct(i).lstrip("0o").rjust(max_longitud) binario = bin(i).lstrip("0b").rjust(max_longitud) # print(binario) longitud = len(binario) x = f"{str(i).rjust(max_longitud)} {octadecimal} {hexadecimal} {binario}" # x = str(i) + octadecimal + hexadecimal + binario print(x)
if name == 'main': n = int(input()) print_formatted(n)
Seems like cookies are disabled on this browser, please enable them to open this website
String Formatting
You are viewing a single comment's thread. Return to all comments →
def print_formatted(n): # your code goes here
if name == 'main': n = int(input()) print_formatted(n)