human
Powers of 2 to required sum | Python3 program to find the blocks for given number ..
Converting the decimal number into its binary equivalent ..
Displaying the output when the bit is '1' in binary equivalent of number ..
Driver Code"
How can the above be solved in Python?
 Give me a code to powers of 2 to required sum and the other steps required?
assistant
#Here is code to powers of 2 to required sum and the other steps required.
 def block ( x ) :
	v = [ ]
	print ( " Blocks ▁ for ▁ % d ▁ : ▁ " % x , end = " " )
	while ( x > 0 ) :
		v . append ( int ( x % 2 ) )
		x = int ( x / 2 )
	for i in range ( 0 , len ( v ) ) :
		if ( v [ i ] == 1 ) :
			print ( i , end = " " )
			if ( i != len ( v ) - 1 ) :
				print ( " , ▁ " , end = " " )
	print ( " " )
block ( 71307 )
block ( 1213 )
block ( 29 )
block ( 100 )