bin()

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...

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn Python on Codecademy

Contributors