# Calculating the dot product of NumPy arrays

## Python Pandas Numpy: Exercise-20 with Solution

Calculate the dot product of two NumPy arrays.

**Sample Solution-1:**

**Python Code:**

```
import numpy as np
# Create two NumPy arrays
array1 = np.array([1, 2, 3])
array2 = np.array([4, 5, 6])
# Calculate the dot product
dot_product = np.dot(array1, array2)
# Display the result
print(dot_product)
```

Output:

32

**Sample Solution-2:**

**Python Code:**

```
import numpy as np
# Create two NumPy arrays
array1 = np.array([1, 2, 3])
array2 = np.array([4, 5, 6])
# Calculate the dot product
dot_product = array1 @ array2
# Display the result
print(dot_product)
```

Output:

21

**Flowchart:**

**Python Code Editor:**

**Previous:** Performing element-wise addition in NumPy arrays.

**Next:** Finding index of maximum and minimum values in a NumPy array.

**What is the difficulty level of this exercise?**

Test your Programming skills with w3resource's quiz.

**Weekly Trends**- 100 Python Projects for Beginners with solution
- Mastering NumPy: 100 Exercises with solutions
- SQL Tutorial
- SQL Inner Join
- Python Exercises, Practice, Solution
- Python Interview Questions and Answers: Comprehensive Guide
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript HTML Form Validation
- Java Collection Exercises