You are viewing a single comment's thread. Return to all comments →
def print_formatted(number): width = len(bin(number)[2:]) + 1 for i in range(1, number+1): Decimal = str(i) Octal = oct(i)[2:] Hexadecimal = hex(i)[2:].upper() Binary = bin(i)[2:] print(Decimal.rjust(width-1)+Octal.rjust(width)+Hexadecimal.rjust(width)+Binary.rjust(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 →