human
Highest power of 2 less than or equal to given number | Python3 program to find highest power of 2 smaller than or equal to n ..
If i is a power of 2.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to highest power of 2 less than or equal to given number and the other steps required.
 def highestPowerof2 ( n ) :
	res = 0 ;
	for i in range ( n , 0 , - 1 ) :
		if ( ( i & ( i - 1 ) ) == 0 ) :
			res = i ;
			break ;
	return res ;
n = 10 ;
print ( highestPowerof2 ( n ) ) ;