bin()

christian.dinh's avatar
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:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn Python on Codecademy