Difference between NumPy.dot() and '*' operation in Python Last Updated : 09 Jul, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report In Python if we have two numpy arrays which are often referred as a vector. The '*' operator and numpy.dot() work differently on them. It's important to know especially when you are dealing with data science or competitive programming problem. Working of '*' operator '*' operation caries out element-wise multiplication on array elements. The element at a[i][j] is multiplied with b[i][j] .This happens for all elements of array.Example: Let the two 2D array are v1 and v2:- v1 = [[1, 2], [3, 4]] v2 = [[1, 2], [3, 4]] Output: [[1, 4] [9, 16]] From below picture it would be clear. Working of numpy.dot() It carries of normal matrix multiplication . Where the condition of number of columns of first array should be equal to number of rows of second array is checked than only numpy.dot() function take place else it shows an error. Example: Let the two 2D array are v1 and v2:- v1=[[1, 2], [3, 4]] v2=[[1, 2], [3, 4]] Than numpy.dot(v1, v2) gives output of :- [[ 7 10] [15 22]] Examples 1: Python3 import numpy as np # vector v1 of dimension (2, 2) v1 = np.array([[1, 2], [1, 2]]) # vector v2 of dimension (2, 2) v2 = np.array([[1, 2], [1, 2]]) print("vector multiplication") print(np.dot(v1, v2)) print("\nElementwise multiplication of two vector") print(v1 * v2) Output : vector multiplication [[3 6] [3 6]] Elementwise multiplication of two vector [[1 4] [1 4]] Examples 2: Python3 import numpy as np v1 = np.array([[1, 2, 3], [1, 2, 3], [1, 2, 3]]) v2 = np.array([[[1, 2, 3], [1, 2, 3], [1, 2, 3]]]) print("vector multiplication") print(np.dot(v1, v2)) print("\nElementwise multiplication of two vector") print(v1 * v2) Output : vector multiplication [[ 6 12 18] [ 6 12 18] [ 6 12 18]] Elementwise multiplication of two vector [[1 4 9] [1 4 9] [1 4 9]] Comment More infoAdvertise with us Next Article Difference between NumPy and SciPy in Python P prajakta_mane Follow Improve Article Tags : Python Python-numpy Practice Tags : python Similar Reads Difference between NumPy and SciPy in Python In Python scientific computing, NumPy provides the core tools for numerical operations and array handling, while SciPy builds on NumPy to offer advanced scientific functions like integration, optimization and signal processing. Simply put, NumPy handles the numbers and SciPy solves the problems.What 2 min read Difference between Numpy array and Numpy matrix While working with Python many times we come across the question that what exactly is the difference between a numpy array and numpy matrix, in this article we are going to read about the same. What is np.array() in PythonThe Numpy array object in Numpy is called ndarray. We can create ndarray using 3 min read Different Ways to Create Numpy Arrays in Python Creating NumPy arrays is a fundamental aspect of working with numerical data in Python. NumPy provides various methods to create arrays efficiently, catering to different needs and scenarios. In this article, we will see how we can create NumPy arrays using different ways and methods. Ways to Create 3 min read Numpy - String Functions & Operations NumPy String functions belong to the numpy.char module and are designed to perform element-wise operations on arrays. These functions can help to handle and manipulate string data efficiently.Table of ContentString OperationsString Information String Comparison In this article, weâll explore the var 5 min read Python: Operations on Numpy Arrays NumPy is a Python package which means 'Numerical Python'. It is the library for logical computing, which contains a powerful n-dimensional array object, gives tools to integrate C, C++ and so on. It is likewise helpful in linear based math, arbitrary number capacity and so on. NumPy exhibits can lik 3 min read numpy.outer() function - Python numpy.outer() function compute the outer product of two vectors. Syntax : numpy.outer(a, b, out = None) Parameters : a : [array_like] First input vector. Input is flattened if not already 1-dimensional. b : [array_like] Second input vector. Input is flattened if not already 1-dimensional. out : [nda 1 min read Like