DEV Community

Discussion on: An Introduction to NumPy

Collapse
 
rodolfoferro profile image
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
Enter fullscreen mode Exit fullscreen mode

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

Collapse
 
gautamkrishnar profile image
Gautam Krishna R

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