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  CSS code snippet - How to select button by type ?

Leave a Reply

Your email address will not be published.

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