bin()

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Jun 15, 2021Updated Sep 3, 2021
Contribute to Docs

Converts an integer into its binary equivalent string.

Syntax

bin(integer)

Example 1

Use bin() function to return the binary equivalent of the integer 1:

print(bin(1))
# Output: 0b1

Example 2

Use bin() to return the binary equivalent of the integer 100:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn Python on Codecademy