human
Write me a code to check whether N can be a Perfect Cube after adding or subtracting K and the other steps required given the following:
Check whether N can be a Perfect Cube after adding or subtracting K | Function to check if a number is a perfect Cube or not.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to check whether N can be a Perfect Cube after adding or subtracting K and the other steps required.
 def isPerfectCube ( x ) :
	cr = int ( x ** ( 1 / 3 ) ) ;
	return ( cr * cr * cr == x ) ;
def canBePerfectCube ( N , K ) :
	if ( isPerfectCube ( N + K ) or isPerfectCube ( N - K ) ) :
		print ( " Yes " ) ;
	else :
		print ( " No " ) ;
if __name__ == " _ _ main _ _ " :
	N = 7 ; K = 1 ;
	canBePerfectCube ( N , K ) ;
	N = 5 ; K = 4 ;
	canBePerfectCube ( N , K ) ;
	N = 7 ; K = 2 ;
	canBePerfectCube ( N , K ) ;