Python bin() FunctionPython Functions

Difficulty Level:
Difficulty Level:

The bin() method converts a given integer into an equivalent binary string.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

print(bin(10))
print(bin(20))

Output:

0b1010
0b10100

Syntax

bin(num)

Parameters

Name Description
num An integer whose binary equivalent is to be calculated

Return Value

It returns the binary string which is equivalent to the given integer.

Advertisement

© 2021 Pythonexample.org, all rights reserved. Privacy Policy | Contact Us