Creating arrays from scratch
It can be helpful to know how to create quick NumPy arrays from scratch in order to test your code. For example, when you are doing math with large multi-dimensional arrays, it's nice to check whether the math works as expected on small test arrays before applying your code to the larger arrays. NumPy has many options for creating smaller synthetic arrays.
With this in mind, it's time for you to create some arrays from scratch! numpy
is imported for you as np
.
This exercise is part of the course
Introduction to NumPy
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create an array of zeros which has four columns and two rows
zero_array = ____
print(zero_array)