Home>

import numpy as np

np.arange (10)

array ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

np.arrange (-10)

array ([], dtype = int64)

Can you tell me if you know how to create a negative array?

If i don't use Numpy, you could do it like this ...

[i for i in range (-1, -10, -2)]
  • Answer # 1

    Three arguments, start, stop, and step can be passed as needed.

    >>>import numpy as np
    >>>np.arange (-10, 0)
    array ([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1])

    numpy.arange — NumPy v1.17 Manual