DEV Community is a community of 755,328 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Discussion on: An Introduction to NumPy

Rodolfo Ferro

This is a great post! I liked it a lot. π»ππ
Dude, I'm now following you on Twitter. ππΌ

What I saw:

In the first code section in NumPy in action, you have the following.

``````>>> a # NumPy Array
array([1, 2, 3, 4])
>>> a2 = np.array([4,5,6,7]) #New NumPy array

>>> a + a2 # Matrix addition
array([ 5,  7,  9, 11])
>>> a + 3 # Addition with a scalar
array([4, 5, 6, 7])

>>> a * a2 # Matrix multiplication
array([ 4, 10, 18, 28])

>>> a * 3 # Multiplication with a scalar
array([ 3,  6,  9, 12])
>>> a ** 3 # Power operator
array([ 1,  8, 27, 64], dtype=int32)
>>> a.sum() # Sum of elements in a
45
``````

Formally, the * operator in NumPy arrays is not for matrix multiplication, you can see that in the next code section that you add. π

Gautam krishna R

Thanks dude... I will correct it... :-D