The remainder() function in Python is used to obtain the remainder of a division of two input arrays, x1 and x2, element-wise.
numpy.remainder(x1, x2, /, out=None, *, where=True)
The remainder() function takes the following parameter values:
x1: This represents the input array of elements, which are the dividends. This is a required parameter value. x2: This represents an array of array, which are the divisors. This is a required parameter value.out: This represents the location where the result is stored. This is an optional parameter value.where: This is the condition over which the input is broadcast. This is an optional parameter value. At a given location where this condition is True, the resulting array is set to the ufunc result. Otherwise, the resulting array retains its original value.kwargs: This represents the other keyword arguments. This is an optional parameter value.The remainder() function returns the remainder, element-wise, of the division of two input arrays.
import numpy as np# creating input arraysx1 = np.array([6, 2, 3])x2 = np.array([5, 2, 1])# implementing the remainder functionmyarray = np.remainder(x1, x2)print(x1)print(x2)print("The remainders of the division element-wise: ", myarray)
numpy module.x1 and x2, using the array() function.numpy.remainder() function on the input arrays. We assign the result to a variable called myarray.x1 and x2to the console.myarray to the console.