In: Computer Science
Assume that bits is a string that only contains the characters "0" and "1". n is an integer variable that is less than the length of bits. Fill in the blanks below to replace bits with a new string that consists of all of the characters of bits from index n through the end, followed by the first n characters of bits.
For example, if bits was "1101010" and n was 3, the new value of bits would be "1010110".
bits=( )+( )
I have answered this question with respect to python.
If you want the answer in any other programming language or on some other platform, then please let me know in the comment section. I will change my answer as per the requirement.
----------------------------------------------------
In python,
Answer:
bits = bits[n:] +
bits[:n]
Explanation:
bits[n:] selects all the characters from nth index
upto the end,
bits[:n] selects all the characters from 0th index
upto the (n-1)th index.
We add both the strings, to get the final string.
The above operation replaces bits with a new
string that consists of all of the characters of
bits from index n through the
end, followed by the first n characters of
bits.
Sample output example in Python
-----------------------------------------------------------------------------------------------------------
Please give a thumbs up if you find this answer helpful.
If it doesn't help, please comment before giving a thumbs
down.
Please Do comment if you need any clarification.
I will surely help you.
Thankyou