TypeError: ‘numpy.float64’ object is not callable [Fixed]

TypeError: 'numpy.float64' object is not callable

The error occurs because you’re attempting to use parentheses () to multiply the arrays together, which Python interprets as trying to call x as a function with y as an argument. Instead, you should use the * operator to perform element-wise multiplication between the arrays.

Here’s the corrected version of your code:

Python
import numpy as np

#define arrays
x = np.array([1, 2, 3, 4, 5])
y = np.array([12, 14, 14, 19, 22])

#perform element-wise multiplication of the arrays
result = x * y

#view result
print(result)

This will correctly multiply corresponding elements of the arrays together, resulting in:

Bash
[12 28 42 76 110]

Each element of result is the result of multiplying the corresponding elements of x and y.

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart