« Numpy

- Create an array ( x1 ) with sequence of number starting from 9 to 17 ( inclusive )
- Create one more array x2 in which each element I = 2 (element of x1) + 8
- Create an array with 4 numbers starting from 2 to 20
- Create an array starting from 2 to 20 and each element is increased by 3
- Create another array of same shape of x1
- Create another array of same shape of x1 but with different random values.

## Create an array ( x1 ) with sequence of number starting from 9 to 17 ( inclusive )

how to create an array with start, stop and step by using arange()
```
import numpy as np
x1=np.arange(9,18)
print(x1) # [ 9 10 11 12 13 14 15 16 17]
```

## Create one more array x2 in which each element I = 2 (element of x1) + 8

```
x2=(2*x1) +8
print(x2) # [26 28 30 32 34 36 38 40 42]
```

## Create an array with 4 numbers starting from 2 to 20

How to create an array with start stop and number of steps by using linspace()
```
x3=np.linspace(2,20,4)
print(x3) # [ 2. 8. 14. 20.]
```

## Create an array starting from 2 to 20 and each element is increased by 3

```
x4=np.arange(2,21,3)
print(x4) # [ 2 5 8 11 14 17 20]
```

## Create another array of same shape of x1

```
import numpy as np
x1=np.arange(9,18)
print(x1)
s1=x1.shape
y1=np.ones(s1)
print(y1)
```

Output
```
[ 9 10 11 12 13 14 15 16 17]
[1. 1. 1. 1. 1. 1. 1. 1. 1.]
```

## Create another array of same shape of x1 but with different random values.

Read more on shape.
```
import numpy as np
x1=np.arange(9,18)
print(x1)
s1=x1.shape
y1=np.ones(s1)
y1=np.random.randint(4,high=10,size=s1)
print(y1)
```

Output
```
[ 9 10 11 12 13 14 15 16 17]
[7 4 5 7 7 6 4 4 4]
```

«Numpy
ones()
bincount()
arange()

← Subscribe to our YouTube Channel here