round

Lutz Horn lutz.horn at posteo.de
Thu Jun 7 07:58:47 EDT 2018


> M = np.array([[0, 9],[2, 7]], dtype=int)
> np.linalg.det(M)
> -18.000000000000004
> round(np.linalg.det(M))

np.linalg.det(M) has type numpy.float64, not float. Try this:

>>> round(float(np.linalg.det(M)))
-18

Lutz




More information about the Python-list mailing list