This language bar is your friend. Select your favorite languages!
Edit summary for version 32 :

Version 31

Version 32

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Code
s = '{:b}'.format(x)
Code
s = '{:b}'.format(x)
Doc URL
https://docs.python.org/3/library/string.html#formatstrings
Doc URL
https://docs.python.org/3/library/string.html#formatstrings
Origin
https://docs.python.org/3/library/string.html#formatstrings
Origin
https://docs.python.org/3/library/string.html#formatstrings