bin()

bin(number)
number :input number in decimal
Return the binary number as string.

Examples

num=5
print(bin(num)) # 0b101
num=47
print(bin(num)) # 0b101111
In our binary output, 0b is allways prefixed. As the output is a string we can remove it like this
num=47
num1=bin(num)
print(num1[2:]) # 101111
Without using bin() and by using format()
num=47
print(format(num,'b')) # 101111
All Built in Functions in Python
max() Bitwise operators using bin() int() float() format()


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2021 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer