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:-
bin function in Python accepts only one parameter that is integer.
- n:– Required An Integer.
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.
Find binary value of 20 using bin function.
x = 20 print(bin(x))
Output will be:- 0b10100
Binary value of 50.
result = bin(50) print(result)
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