There is an unexpected output when I am dealing with binary number in Python 3.
We can easily convert any integer to binary by built-in bin() function. For example:
>>>bin(4243125)
Here's the issue when I try to add 2 binary function:
>>>bin(x)+bin(y)
The output is concatenation of two binary number, not addition of binary number. The output of binary function has become a string.
Addition in a binary function works fine:
>>>bin(x+y)
And try to add two binary number without bin() is viable too:
>>>0b100+0b10111
What is the reasons/purposes of setting a bin() output to a string?
101is one hundred and one, not five, and 2. (the exception, in Python 2.x only) a leading0means octal, so0101 == 65. Therefore, to avoid confusion,binreturns a string prefixed with0b.strorrepr). What is it that you're trying to achieve?