Skip to content
Advertisement

Tag: binary

Reading binary lines not matching file lines after first line

I’m trying to read and print the binary data of a file but notice after reading the first line, with 128 bits, the subsequent lines printed out do not match the lines when I look at the binary data manually with notepad++. Answer The problem is that when dc==16 then your program prints whole line but the current x value

how to convert bytes to binary using python

so i want convert bytes to binary in python, but when i run it, there’s none in the result and i got error: ‘NoneType’ object is not iterable here’s the code i tried Answer Your function currently returns None because there’s no return statement. Perhaps instead of using print, you should modify your functions to return an array of outputs.

What are these symbols in ‘bytes’ type?

So, I have a single byte in bytes format looking something like that: It is quite easy to understand that a single byte is the two symbols(0-F) after ‘x’ But sometimes the pattern doesn’t match, containing more than two symbols after ‘x’. So, for example, if I use secrets.token_bytes() I can get something like that: Or, using hashlib module: So,

Data type somehow gets converted when appended to a list

I am trying to convert text to binary using ASCII encoding, and then decode the binary back to text as proof of concept for a larger project. The following code works well and does what it is supposed to do: However, as soon as I try to append the given value of output_data to a list within the for loop,

how can I split the elements of a list of binary numbers?

I’m trying to split the elements of a list of binary numbers as follows : bin_list=[‘000101111000′,’011110111011’] Expected result: bin_list=[[0,0,0,1,0,1,1,1,1,0,0,0],[0,1,1,1,1,0,1,1,1,0,1,1]] I think that would be a list of a list of integers what I’m trying to get?? I tried searching a similar procedure and I’ve tried some but I can’t get it right pls help thanks!! Answer This could be done

Given a list of binary numbers (0s and 1s), determine the number of possible arrangements of distinct binary sequences using given 0s and 1s

Given a list of binary numbers (0s and 1s), determine the number of possible arrangements of distinct binary sequences using given 0s and 1s. Input Format: A single line of input containing 0s and 1s Output Format: Print an integer value indicating the number of possible arrangements using given 0s and 1s Example: Input: 0 1 0 1 Output: 6

Advertisement