``````

In [1]:

import numpy as np

``````
``````

In [2]:

a_1d = np.arange(10)
print(a_1d)

``````
``````

[0 1 2 3 4 5 6 7 8 9]

``````
``````

In [3]:

print(a_1d[0])

``````
``````

0

``````
``````

In [4]:

print(a_1d[4])

``````
``````

4

``````
``````

In [5]:

print(a_1d[-1])

``````
``````

9

``````
``````

In [6]:

print(a_1d[-4])

``````
``````

6

``````
``````

In [7]:

# print(a_1d[100])
# IndexError: index 100 is out of bounds for axis 0 with size 10

``````
``````

In [8]:

# print(a_1d[-100])
# IndexError: index -100 is out of bounds for axis 0 with size 10

``````
``````

In [9]:

a_2d = np.arange(12).reshape(3, 4)
print(a_2d)

``````
``````

[[ 0  1  2  3]
[ 4  5  6  7]
[ 8  9 10 11]]

``````
``````

In [10]:

print(a_2d[0, -1])

``````
``````

3

``````
``````

In [11]:

print(a_2d[0])

``````
``````

[0 1 2 3]

``````
``````

In [12]:

print(a_2d[0, :])

``````
``````

[0 1 2 3]

``````
``````

In [13]:

print(a_2d[:, 0])

``````
``````

[0 4 8]

``````
``````

In [14]:

print(type(a_2d[0, -1]))

``````
``````

<class 'numpy.int64'>

``````
``````

In [15]:

print(type(a_2d[0]))

``````
``````

<class 'numpy.ndarray'>

``````