The bin() function is used to convert an integer number to a binary string (preceded by “0b”). The binary notation is the representation of integers in base 2, the notation only uses the digits  0 and 1 .

The bin() function takes an integer argument, and returns the corresponding binary representation of the decimal number.

Syntax:
bin(integer)
copy
ExampleEdit & Run
print( bin(1) )
print( bin(2) )
print( bin(4) )
print( bin(15) )
print( bin(50) )
print( bin(64) )
copy
Output:
0b1 0b10 0b100 0b1111 0b110010 0b1000000 [Finished in 0.010834950953722s]