Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published May 10, 2024
Contribute to Docs

In NumPy, the .dot() method computes the dot product of two arrays. For 1-D arrays, it provides a scalar value. When both arrays are 2-D, it performs matrix multiplication, resulting in a new 2-D array. Further details about various scenarios, including arrays with more than two dimensions, can be found in the NumPy .dot() documentation. This method is widely utilized in linear algebra and numerical computations.


numpy.dot(a, b, out=None)
  • a: The first array, which could be 1-D, 2-D, or higher dimensional.
  • b: The second array, having compatible dimensions with a, and also could be 1-D, 2-D, or higher dimensional.
  • out: Optional parameter that specifies the output array where the result is stored. If not provided, a new array is created.


The usage of the .dot() method is demonstrated in the following example:

import numpy as np
# Define two arrays
array_a = [3,4,5]
array_b = [1,2,3]
# Compute the dot product and print the result
print(np.dot(array_a, array_b))

The above code will produce the following output:


Codebyte Example

Visit us
Hide code
Hide output
Hide output

All contributors

Looking to contribute?

Learn Python:NumPy on Codecademy