Difficulty: beginner
Estimated Time: 15 minutes

This scenario is the introduction to the basic concepts for the numpy library.

It's not a comprehensive tutorial, but enough to follow the next scenarios in the Deep Learning course.


You've completed Numpy Basics scenario.

You've learned the following concepts using Python numpy library:

  • Creating the array
  • Operations on arrays
  • Applying functions
  • Perform linear algebra operations

Numpy Basics

Step 1 of 4

Creating the arrays

Numpy package is one the most widely used library in the Python environment. It enables straightforwardly vectorising the operations. In the world of Deep Learning and Neural Networks, this is a desirable quality.

Numpy's main object is a multidimensional array storing elements of the same type, usually numbers. The arrays (umpy.array) created using the library differ from the ones in Python standard library (array.array). Let us first run the Python command line and import the package.


import numpy as np

There are several ways on how to create the arrays. The easiest is to provide the set of value, by passing a regular Python list or tuple using the array function.

np.array([2, 4, 15]) np.array([[1, 2], [3, 4], [5, 6]])

The transformations change sequences of sequences into two-dimensional arrays, sequences of sequences of sequences into three-dimensional arrays, and so on. Notice that the following line will return with the error:

np.array(2, 4, 15)

To find out about the shape of the array use the following:

a = np.array([[1, 2], [3, 4], [5, 6]]) a.shape

To change it, use the reshape function:

a.reshape(2, 3)

You may find the functions zeros and ones useful to create arrays containing only 0s or 1s:

np.zeros((3, 4)) np.ones((2, 3))

For the randomly generated numbers apply:


This tab will not be visible to users and provides only information to help authors when creating content.

Creating Katacoda Scenarios

Thanks for creating Katacoda scenarios. This tab is designed to help you as an author have quick access the information you need when creating scenarios.

Here are some useful links to get you started.

Running Katacoda Workshops

If you are planning to use Katacoda for workshops, please contact [email protected] to arrange capacity.

Debugging Scenarios

Below is the response from any background scripts run or files uploaded. This stream can aid debugging scenarios.

If you still need assistance, please contact [email protected]