I have task of converting an array with binary numbers into a decimal number. My array code looks like this:
koo = np.random.randint(2, size=10)
print(koo)
Example of the output is:
[1 0 1 0 0 0 0 0 1 0]
And what I'm supposed to do is to turn it into a string (1010000010), in order to then turn it into a decimal number (642). What could be a way to do this?
For this task I have to create it with the array, I cannot use np.binary_repr()
I have tried solving it with the solution offered here, but when working on it the numbers would be wildly different from what's true (i.e.: 1011111010 was 381 according to the program, while in reality it's 762)
Anybody knows how to solve this problem? Thank you in advance!