Quantcast
Channel: Convert int to binary string in Python - Stack Overflow
Viewing all articles
Browse latest Browse all 74

Answer by mukundan for Python int to binary string?

$
0
0
def binary(decimal) :    otherBase = ""    while decimal != 0 :        otherBase  =  str(decimal % 2) + otherBase        decimal    //=  2    return otherBaseprint binary(10)

output:

1010


Viewing all articles
Browse latest Browse all 74

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>