The power() function raises the values from the first array to the power of the corresponding values in the second array and returns the results in a new array.
Raise the values in arr1 to the power of the values in arr2:
import numpy as np arr1 = np.array([10, 20, 30, 40, 50, 60]) arr2 = np.array([3, 5, 6, 8, 2, 33]) newarr = np.power(arr1, arr2) print(newarr) |
The example above will yield [1000, 3200000, 729000000, 6553600000000, 2500, 0] , which results from 10310^3, 20620^6, 30630^6, and so on. |
Both the mod() and remainder() functions return the remainder of the values from the first array when divided by the corresponding values in the second array, producing a new array with the results.
Return the remainders:
import numpy as np arr1 = np.array([10, 20, 30, 40, 50, 60]) arr2 = np.array([3, 7, 9, 8, 2, 33]) newarr = np.mod(arr1, arr2) print(newarr) |
You obtain the same result when using the remainder() function:
Return the remainders:
import numpy as np arr1 = np.array([10, 20, 30, 40, 50, 60]) arr2 = np.array([3, 7, 9, 8, 2, 33]) newarr = np.remainder(arr1, arr2) print(newarr) |