Curriculum
Course: NumPy
Login

Curriculum

NumPy

Text lesson

Power

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.

Example

Raise the values in arr1 to the power of the values in arr2:

import numpy as np

arr1 = np.array([102030405060])
arr2 = np.array([3568233])

newarr = np.power(arr1, arr2)

print(newarr)
The example above will yield [1000, 3200000, 729000000, 6553600000000, 2500, 0], which results from 10310^320620^630630^6, and so on.

Remainder

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.

Example

Return the remainders:

import numpy as np

arr1 = np.array([102030405060])
arr2 = np.array([3798233])

newarr = np.mod(arr1, arr2)

print(newarr)

You obtain the same result when using the remainder() function:

Example

Return the remainders:

import numpy as np

arr1 = np.array([102030405060])
arr2 = np.array([3798233])

newarr = np.remainder(arr1, arr2)

print(newarr)