Write a NumPy program to create a function cube which cubes all the elements of an array.
import numpy as np def cube(e): it = np.nditer([e, None]) for a, b in it: b[...] = a*a*a return it.operands[1] print(cube([1,2,3]))
Sample Output:
[ 1 8 27]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer