Pages

11 April, 2022

Python bin() Function

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.

Signature

  • bin(n)

Parameters

  • n - An integer

Return

It returns the binary representation of a specified integer.

Python bin() Function Example 1

  1. x =  10  
  2. y =  bin(x)  
  3. print (y)  

Output:

0b1010

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

No comments:

Post a Comment

Thanks