Language

Data Analysis · Lesson 32 of 56

Numpy

Source: 10-Data Analysis With Python/10.1-numpy.ipynb

Start here — no coding background needed

What you will learn

Fast number arrays — foundation for data science.

In simple words

NumPy stores numbers in grids — think Excel cells but faster for math.

Spreadsheet-style work with code — for data jobs. Beginners: read concepts, run small examples.

Easy example — try this first

Easy example — run this first. Change values and press Run again.

Python

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference notes (from full bootcamp)

Optional — deeper detail for when you are ready

Numpy

NumPy is a fundamental library for scientific computing in Python. It provides support for arrays and matrices, along with a collection of mathematical functions to operate on these data structures. In this lesson, we will cover the basics of NumPy, focusing on arrays and vectorized operations.

Example HCL
HCL
!pip install numpy

Browser practice only — full example needs Python on your computer (files, Flask, threads, etc.).

Reference example
Python
Output
Expected (from notebook):
[1 2 3 4 5]
<class 'numpy.ndarray'>
(5,)

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
array([[1, 2, 3, 4, 5]])

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
(1, 5)

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
[[1 2 3 4 5]
 [2 3 4 5 6]]
(2, 5)

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
array([[0],
       [2],
       [4],
       [6],
       [8]])

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
array([[1., 1., 1., 1.],
       [1., 1., 1., 1.],
       [1., 1., 1., 1.]])

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]])

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
Array:
 [[1 2 3]
 [4 5 6]]
Shape: (2, 3)
Number of dimensions: 2
Size (number of elements): 6
Data type: int32
Item size (in bytes): 4

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
Addition: [11 22 33 44 55]
Substraction: [ -9 -18 -27 -36 -45]
Multiplication: [ 10  40  90 160 250]
Division: [0.1 0.1 0.1 0.1 0.1]

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
[1.41421356 1.73205081 2.         2.23606798 2.44948974]
[  7.3890561   20.08553692  54.59815003 148.4131591  403.42879349]
[ 0.90929743  0.14112001 -0.7568025  -0.95892427 -0.2794155 ]
[0.69314718 1.09861229 1.38629436 1.60943791 1.79175947]

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
Array : 
 [[ 1  2  3  4]
 [ 5  6  7  8]
 [ 9 10 11 12]]

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
[[ 6  7]
 [10 11]]

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
1
[[3 4]
 [7 8]]

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
array([[ 7,  8],
       [11, 12]])

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
[[100   2   3   4]
 [  5   6   7   8]
 [  9  10  11  12]]

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
[[100   2   3   4]
 [100 100 100 100]
 [100 100 100 100]]

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
Normalized data: [-1.41421356 -0.70710678  0.          0.70710678  1.41421356]

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
Mean: 5.5
Median: 5.5
Standard Deviation: 2.8722813232690143
Variance: 8.25

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Reference example
Python
Output
Expected (from notebook):
array([5, 6, 7, 8])

Runs in your browser via Pyodide — no server. First run may take a few seconds.

Practice test — try yourself

Write code, press Check. Wrong answer shows the correct code to copy & run.

You learned "Numpy". Use print() to show: Done: Numpy

Hint: Use one print() with the exact text.

Python