- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Return the remainder of division with dividend and divisor array-like in Numpy

To return the element-wise remainder of division, use the **numpy.remainder()** method in Python Numpy. Here, the 1st parameter is the Dividend array. The 2nd parameter is the Divisor array. Computes the remainder complementary to the floor_divide function. It is equivalent to the Python modulus operator "x1 % x2" and has the same sign as the divisor x2. The MATLAB function equivalent to np.remainder is mod.

The out is a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

## Steps

At first, import the required library −

import numpy as np

Create an array. This is the dividend array −

arr = np.array([3, 9, 14, 22, 76, 81, 91])

Display the array −

print("Array...\n", arr)

Get the type of the array −

print("\nOur Array type...\n", arr.dtype)

Get the dimensions of the Array −

print("\nOur Array Dimension...\n",arr.ndim)

Get the shape of the Array −

print("\nOur Array Shape...\n",arr.shape)

Divisor array −

divisor = np.array([5, 7, 3, 2, 2, 7, 7])

To return the element-wise remainder of division, use the numpy.remainder() method. Here, the 1st parameter is the Dividend array. The 2nd parameter is the Divisor array −

print("\nResult (remainder)...\n",np.remainder(arr, divisor))

## Example

import numpy as np # Create an array # This is the dividend array arr = np.array([3, 9, 14, 22, 76, 81, 91]) # Display the array print("Array...\n", arr) # Get the type of the array print("\nOur Array type...\n", arr.dtype) # Get the dimensions of the Array print("\nOur Array Dimension...\n",arr.ndim) # Get the shape of the Array print("\nOur Array Shape...\n",arr.shape) # Divisor array divisor = np.array([5, 7, 3, 2, 2, 7, 7]) # To return the element-wise remainder of division, use the numpy.remainder() method in Python Numpy # Here, the 1st parameter is the Dividend array # The 2nd parameter is the Divisor array print("\nResult (remainder)...\n",np.remainder(arr, divisor))

## Output

Array... [ 3 9 14 22 76 81 91] Our Array type... int64 Our Array Dimension... 1 Our Array Shape... (7,) Result (remainder)... [3 2 2 0 0 4 0]

- Related Questions & Answers
- Return the element-wise remainder of division in Numpy
- Return the element-wise remainder of division with modulo operation in Numpy
- Return the element-wise remainder of division with fmod() operation in Numpy
- Return a new array of given shape and type, filled with array-like in Numpy
- Return the greatest common divisor and lowest common multiple in Numpy
- Divide a given scalar element with masked array elements and return arrays with Quotient and Remainder in NumPy
- Return element-wise quotient and remainder simultaneously in Python Numpy
- Divide masked array elements by a given scalar element and return arrays with Quotient and Remainder in NumPy
- How to perform integer division and get the remainder in JavaScript?
- Return the largest integer smaller or equal to the division of the inputs in Numpy
- Return a view of the masked array with axis1 and axis2 interchanged in Numpy
- Return the identity array in Numpy
- Return the fractional and integral parts of array values in Numpy
- Return the transpose of the masked array in NumPy
- Return the floor of the array elements in Numpy