=====Problem Statement=====
Given an integer, n, print the following values for each integer i from 1 to n:
1. Decimal
2. Octal
3. Hexadecimal (capitalized)
4. Binary

The four values must be printed on a single line in the order specified above for each i from 1 to n. Each value should be space-padded to match the width of the binary value of n.

=====Input Format=====
A single integer denoting n.

=====Constraints=====
1 ≤ n ≤ 99

=====Output Format=====
Print n lines wehere each line i (in the range 1 ≤ i ≤ n) contains the respective decimal, octal, capitalized hexadecimal, and binary values of i. Each printed value must be formatted to the width of the binary value of n.

Difficulty: introductory

Starter code:

def print_formatted(number):
    # your code goes here

if __name__ == '__main__':
    n = int(input())
    print_formatted(n)

Solutions:
n = int(input().strip())
w = len(str(bin(n))[2:])
for i in range(1,n+1,1):
    o = str(oct(i))[2:]
    h = str(hex(i))[2:]
    h = h.upper()
    b = str(bin(i))[2:]
    d = str(i)
    print(('{:>{width}} {:>{width}} {:>{width}} {:>{width}}'.format(d,o,h,b,width=w)))