human
Check whether the binary equivalent of a number ends with given string or not | Function returns true if s1 is suffix of s2.
Function to check if binary equivalent of a number ends in "111" or not.
To store the binary number.
Count used to store exponent value.
Driver code"
How can the above be solved in Python?
 Give me a code to check whether the binary equivalent of a number ends with given string or not and the other steps required?
assistant
#Here is code to check whether the binary equivalent of a number ends with given string or not and the other steps required.
 def isSuffix ( s1 , s2 ) :
	n1 = len ( s1 )
	n2 = len ( s2 )
	if ( n1 > n2 ) :
		return False
	for i in range ( n1 ) :
		if ( s1 [ n1 - i - 1 ] != s2 [ n2 - i - 1 ] ) :
			return False ;
	return True ;
def CheckBinaryEquivalent ( N , s ) :
	B_Number = 0 ;
	cnt = 0 ;
	while ( N != 0 ) :
		rem = N % 2 ;
		c = pow ( 10 , cnt ) ;
		B_Number += rem * c ;
		N //= 2 ;
		cnt += 1 ;
	bin = str ( B_Number ) ;
	return isSuffix ( s , bin ) ;
if __name__ == " _ _ main _ _ " :
	N = 23 ;
	s = "111" ;
	if ( CheckBinaryEquivalent ( N , s ) ) :
		print ( " Yes " )
	else :
		print ( " No " )