The Dot Product Between Arrays

nparray1 = np.array([0, 1, 2, 3]) # Define an array
nparray2 = np.array([4, 5, 6, 7]) # Define an array

1. Recommended Way

way_1 = np.dot(nparray1, nparray2)
Output : 38

2. Okayish Way

way_2 = np.sum(nparray1 * nparray2)
Output : 38

3. Geeks way

way_3 = nparray1 @ nparray2
Output : 38

4. Noobs way

#(As you never should do:)
way_4 = 0
for a, b in zip(nparray1, nparray2):
way_4 += a * b
Output : 38

</happy coding>

--

--

--

Arranging 0’s and 1’s in the exact right order !!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Which Type of Apps can you Build in Python?

Managed File Transfer (MFT) — Routing files to different folders

sharepoint secure managed file transfer

Self Join Table Association with Ruby on Rails

3 Tips to Boost the Performance of your Varnish Cache

Why Regular Web Maintenance Is As Important As Regular Maintenance of Your Car

Boogie-Woogie NFT Run #1

Can’t code? Here’s how you can still build an app…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Prajeet Singh Kalchuri

Prajeet Singh Kalchuri

Arranging 0’s and 1’s in the exact right order !!

More from Medium

The Pink Stapler Test

Bias towards a certain norm in deep learning models

An Exploration of Seattle Airbnb Data

SCORM Based Learning | OpenGrowth

Types and Risks of Artificial Intelligence with our eyes on Superhuman AI