Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

convert decimal to binary in python

======= Convert Decimal to Binary in Python ========
my_int = 10;
#Method 1: using bin
n1 = bin(my_int).replace("0b", "")   #1010
or n1 = bin(my_int)[2:] 

#Method 2: using format
n2 = "{0:b}".format(my_int)       
or n2 = format(my_int, 'b')        #1010
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #decimal #binary #python
ADD COMMENT
Topic
Name
3+2 =