Skip to content

Convert decimal to binary in Python

Advertisements

We can use bin() to convert a given decimal number into its binary equivalent.

print(bin(1))

#0b1

print(bin(22))

#0b10110

print(bin(2312))

#0b100100001000

See also  Combine two lists into a dictionary in Python

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.