#!/usr/bin/env python3# Function to reverse bits of the given number and return new numberdefreverse_bits(n):rev=0# traversing bits of 'n' from the rightwhile(n>0):# bitwise left shift 'rev' by 1rev=rev<<1# if current bit is '1'if(n&1==1):rev=rev^1# bitwise right shift 'n' by 1n=n>>1# required numberreturnrev