N-Dimensional Arrays


NumPy's core functionality is the n-dimensional array, an array of python data types capable of storing multiple dimensions or layers of arrays. Most commonly it is used for 1 dimensional lists and 2 dimensional matrices. The array is constructed using the array command. Note that you need to precede the command with the name given to the numpy package (This is required for all NumPy-specific commands). Here, we use np for the package name.

Sage Cell


import numpy as np
a = array([1, 2, 3], [4, 5, 6])
print a


Array of Zeros

Using the zeros constructor, we can create an array pre-filled with floating-point zeros. The constructor takes a tuple determining the shape of the array as a parameter.


import numpy as np
a = np.zeros((2, 3))
print a


Primary Tags:

Secondary Tags:

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.

Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.




Date: 03 Apr 2019 16:39

Submitted by: Zane Corbiere

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License