Step 1: Create two NumPy arrays
a → [1, 2, 3]
b → [4, 5, 6]
๐น Step 2: Compute dot product
np.dot(a, b) performs dot product (inner product) between the two arrays.
Formula for dot product:
๐น Step 3: Calculate
๐น Step 4: Print result
print(np.dot(a, b))Output:
32✅ Final Explanation
np.dot(a, b) multiplies each corresponding element of a and b, then sums all the products — returning a single scalar value (32).
This operation is widely used in:
-
Linear algebra
-
Machine learning (e.g., computing weighted sums in neural networks)
-
Vector mathematics


0 Comments:
Post a Comment