Reversing the binary of the given number in python

>>> a=int(input('Enter base 10 natural number: '))
Enter base 10 natural number: 42
>>> b = bin(a)
>>> a = int(b[:2]+b[2:][::-1], 2)
>>> a
21

Comments

Pages

Categories

Tags