63 036
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #58039 in Python for locky

Question #58039
How to Permute the positions of the last two nibbles of a number. In other words, a block
Expert's answer
x=int(input())
x=list(bin(x)[2:])

x_change=[]
x_finish=[]

if len(x)<8 :
x_change = [ '0' for i in range (8-len(x))]
for i in range(len(x)):
x_change.append(x[i])
else :
x_change=x

if len(x_change)==8 :
for i in range(4,8): x_finish.append(x_change[i])
for i in range(4): x_finish.append(x_change[i])
else:
for i in range(len(x_change)-8): x_finish.append(x_change[i])
for i in range(len(x_change)-4,len(x_change)): x_finish.append(x_change[i])
for i in range(len(x_change)-8,len(x_change)-4): x_finish.append(x_change[i])

x_finish=int(''.join(x_finish),2)
print(x_finish)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions