human
Perfect cubes in a range | Python3 code for Efficient method to print cubes between a and b.
An efficient solution to print perfect cubes between a and b.
Find cube root of both a and b.
Print cubes between acrt and bcrt.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to perfect cubes in a range and the other steps required.
 def cbrt ( n ) :
	return ( int ) ( n ** ( 1. / 3 ) )
def printCubes ( a , b ) :
	acrt = cbrt ( a )
	bcrt = cbrt ( b )
	for i in range ( acrt , bcrt + 1 ) :
		if ( i * i * i >= a and i * i * i <= b ) :
			print ( i * i * i , " ▁ " , end = " " )
a = 24
b = 576
print ( " Perfect ▁ cubes ▁ in ▁ given ▁ range : " )
printCubes ( a , b )