Menu Close

Python bin() Function

In this python built-in functions tutorial, we are going to learn all about the Python bin function to get the binary value of a specified integer.
In the previous python tutorial, we have seen Python any function along with examples.

What is Python bin() Function?

Python bin function is a built-in function that is used to find the binary value of a specified integer. The result of the bin function in python will always start with the prefix 0b.


The syntax of bin function in python is:-


Parameter Value

bin function in Python accepts only one parameter that is integer.

  • n:– Required An Integer.

Return Value

Return value of bin function in python is binary value.

Python bin function example

Here we will use bin method in python to get binary value of given integer.

Example 1:

Find binary value of 20 using bin function.

x = 20

Output will be:- 0b10100

Example 2:

Binary value of 50.

result = bin(50)

Output will be:- ob110010


In this tutorial, you have learned the bin method in python to find the binary value of a given integer. This is the best python built-in function for getting binary values.

If this article helped you, please keep visiting for further python built-in functions tutorial.

For more information:- Click Here

Python any() Function
Python bool() Function

Was this post helpful?

Related Posts

Leave a Reply

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