How to convert int to binary in Python

3 Answers

0 votes
binary = bin(13)

print(binary)





'''
run:

0b1101

'''

 



answered Apr 22, 2021 by avibootz
0 votes
binary = format(13, "b")

print(binary)





'''
run:

1101

'''

 



answered Apr 22, 2021 by avibootz
0 votes
binary = "{0:b}".format(13)

print(binary)





'''
run:

1101

'''

 



answered Apr 22, 2021 by avibootz

Related questions

1 answer 136 views
1 answer 154 views
2 answers 214 views
3 answers 217 views
217 views asked Apr 23, 2021 by avibootz
1 answer 179 views
2 answers 135 views
1 answer 122 views
...