human
Check whether all the bits are unset in the given range or not | function to check whether all the bits are unset in the given range or not.
calculating a number ' num ' having ' r ' number of bits and bits in the range l to r are the only set bits.
new number which will only have one or more set bits in the range l to r and nowhere else.
if new num is 0 , then all bits are unset in the given range.
else all bits are not unset.
Driver Code"
How can the above be solved in Python?
 What is a code to check whether all the bits are unset in the given range or not and the other steps required?
assistant
#Here is code to check whether all the bits are unset in the given range or not and the other steps required.
 def allBitsSetInTheGivenRange ( n , l , r ) :
	num = ( ( 1 << r ) - 1 ) ^ ( ( 1 << ( l - 1 ) ) - 1 )
	new_num = n & num
	if ( new_num == 0 ) :
		return " Yes "
	return " No "
if __name__ == " _ _ main _ _ " :
	n = 17
	l = 2
	r = 4
	print ( allBitsSetInTheGivenRange ( n , l , r ) )