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
...