9951 explained code solutions for 126 technologies


python-numpyGet quadratic equation roots


import numpy as np
arr = np.array([1, 4, 4]) # x^2 + 4*x + 4
roots = np.roots(arr)ctrl + c
import numpy as np

load Numpy module for Python

np.array

declare Numpy array

[1, 4, 4]

this array declares sample polynom x^2 + 4*x + 4 to get roots for

.roots(

return array with roots

roots

will contain calculated roots