+ 3

# Error, what's wrong with this code

from numpy import* s="10 20 13 ; 50 60 70 ; 33 96 55" b=matrix(s) print(b) a =b.product(0) print(a)

2 Answers

+ 9

Did you read the error message? It says there is no "product" function. Look up how the function is actually called.

+ 5

# Hi Mr Boy !
# Instead of 'product', use 'prod' (this will make it work).
# It's not recommended to use '*'.
# And to increase readability, here with 'prod' as a function:
import numpy as np
s = "10 20 13; 50 60 70; 33 96 55"
b = np.matrix(s)
print("Matrix representation: ")
print(b)
a = np.prod(b, axis=0)
print("\nProduxt along axis 0: ")
print(a)