Introduction to NumPy

Here's the array as seen in the notes:

In [1]:
import numpy as np

my_array = np.array([1, 2, 3, 4, 5])

my_array[4] = 999

Get the first three elements:

In [2]:
my_array[:3]
Out[2]:
array([1, 2, 3])

And set it back to how it was:

In [3]:
my_array[4] = 5
print(my_array)
[1 2 3 4 5]