Update README.md

Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
This commit is contained in:
David Rotermund 2023-12-14 20:54:05 +01:00 committed by GitHub
parent d74df5d3f0
commit a123a4694b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,3 +34,37 @@ numpy.arange([start, ]stop, [step, ]dtype=None, *, like=None)
> **When using a non-integer step, such as 0.1, it is often better to use numpy.linspace.**
>
>
Examples:
```python
import numpy as np
print(np.arange(5)) # -> [0 1 2 3 4]
print(np.arange(0, 5)) # -> [0 1 2 3 4]
print(np.arange(2, 5)) # -> [2 3 4]
print(np.arange(0, 5, 2)) # -> [0 2 4]
```
It can be nicely combined with **reshape()**:
```python
import numpy as np
print(np.arange(0, 9).reshape(3, 3))
```
Output:
```python
[[0 1 2]
[3 4 5]
[6 7 8]]
```
**Do not use it with non-integer values for step!!!** This can happen and you don't want this to happen:
```python
import numpy as np
print(np.arange(-3, 0, 0.5, dtype=int)) # -> [-3 -2 -1 0 1 2]
```