NumPy is a Python Library for working with matrices. You can create a NumPy array via:
import numpy as np
demo_array = np.array([3, 8, 11, 14])
You can create multidimensional arrays as well. Eg:
multi_array = np.array([[8, 12], [4, 16], [8, 33]])
You can create sequences of numbers in numpy via arange
. Note: the sequence given will include the min value, but not the max value. So to get a sequence of all numbers between 1-100, you’d use:
np.arange(1,101)
Note: You can perform mathematical operations on all values in a matrix easily. For example:
one_to_one_hundred = np.arange(1,101)
two_to_two_hundred_in_increments_of_two = one_to_one_hundred * 2