You are viewing a single comment's thread. Return to all comments →
def print_formatted(number): width = len(bin(number)[2:]) for i in range(1,number+1): decimal = i octal = oct(i)[2:] hexadecimal = hex(i)[2:].upper() binary = bin(i)[2:] print(f'{decimal:>{width}} {octal:>{width}} {hexadecimal:>{width}} {binary:>{width}}') 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 →