bin()

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

Looking to contribute?

Learn Python on Codecademy