number :input number in decimal
Return the binary number as string.
print(bin(num)) # 0b101
In our binary output,
print(bin(num)) # 0b101111
0b is always prefixed. As the output is a string we can remove it like this
Without using bin() and by using format()
print(num1[2:]) # 101111
All Built in Functions in Python
print(format(num,'b')) # 101111
max() Bitwise operators using bin()
Subscribe to our YouTube Channel here
This article is written by plus2net.com team.