Python – Print binary representation

Spread the love

For print integer number in binary representation should to use format function. Example:

print("{0:b}".format(123))

You will see 123 in binary representation:

>>> print("{0:b}".format(123))
1111011

Leave a Reply