def print_formatted(number):
width = len(bin(number)[2:])
for i in range(1, number+1):
deci = str(i)
octa = oct(i)[2:]
hexa = hex(i)[2:].upper()
bina = bin(i)[2:]
print(deci.rjust(width),octa.rjust(width),hexa.rjust(width),bina.rjust(width))
# your code goes here
if __name__ == '__main__':
n = int(input())
print_formatted(n)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter