Posts

Showing posts with the label string formatting

Python-HackerRank-String Formatting

def   print_formatted ( number ):      results  =  []      for   i   in   range ( 1 ,   n + 1 ):          decimal  =  str ( i )          octal  =  str ( oct ( i )[ 2 :])          hex_  =  str ( hex ( i )[ 2 :]) . upper ()          binary  =  str ( bin ( i )[ 2 :])          results . append ([ decimal ,   octal ,   hex_ ,   binary ])      # print(results)      width  =  len ( results [ -1 ][ 3 ])        # print(width) # largest binary number      for   i   in   results :          print (...