Python NumPy Introduction - chrisbitm/python GitHub Wiki

# Imports
import numpy as np

# Variables
arr = np.array([2, 4, 6, 8, 10])

# Output
print(arr)
print(type(arr))
  • import numpy as np will allow you to use the Python Library known as NumPY. The as Keyword allows you to refer it as its Alias.
  • arr = np.array([1, 2, 3, 4, 5]) assigns Numbers 1 -5 to an Array and is stored in arr Variable.
  • print(arr) displays its contents to Console.
  • print(type(arr)) displays the Data Type to Console, which is <class 'numpy.ndarray'>

You can also do this without an Alias. It's as follows

# Imports
import numpy

# Variables
arr = numpy.array([3, 5, 7, 11])

# Output
print(arr)
print(type(arr))