+ 8
You have to use bin() function. Its arguments have to be integers, so you have to convert your string first.
For example:
b = '256'
print(bin(int(b)))
>>>
0b100000000
where bin() returns a string again, which is a binary representation of the integer.
---
If you want to convert the other way round, it is a bit simpler. You just use int(x, y) where x is a binary string representation and y is the base of the number (in this case 2):
print(int('1000', 2))
>>>
8
This time a base10 integer is returned.
+ 4
You mean to convert, let's say "8192" into 10000000000 and back?