Python bin() Function

The python bin() function is used to return the binary representation of a specified integer. A result always starts with the prefix 0b.

Python bin() Function Syntax

It has the following syntax:

bin(n)

Parameters

  • n: It represents an integer.

Return

It returns the binary representation of a specified integer.

Python bin() Function Example 1

Let us take an example to demonstrate the python bin() function.

x =  10  

y =  bin(x)  

print (y)

Output:

0b1010

Note: The result will always be prefixed with ‘0b’.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *