Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python format to print dec oct hex and bin

n = int(input())
w = len("{0:b}".format(n))
for i in range (1, n+1):
  print("{0:{width}d}{0:{width}o}{0:{width}X}{0:{width}b}".format(i, width=w))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #format #print #dec #oct #hex #bin
ADD COMMENT
Topic
Name
5+8 =