Skip to content
Learn Netverks

Lesson

Step 1/36 3% through track

intro

Introduction to NumPy

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~4 min
Level
beginner

This lesson

An orientation to the NumPy track—ndarray creation, dtypes, vectorization, and links to Pandas/SciPy next.

You need ndarray fundamentals before Pandas and ML libraries—otherwise DataFrame internals and broadcasting errors feel magical.

You will apply Introduction to NumPy in contexts like: Notebooks, feature engineering pipelines, and custom numerical code.

Read the narrative, run `import numpy as np` snippets in the playground (install NumPy with pip if the runner lacks it), tweak shapes and dtypes, and complete MCQs. Also read the interview prep blocks; print `.shape` and `.dtype` after every new array you create.

After /python/intro and ideally /data-science/intro workflow—before /pandas/intro labeled tables.

How this NumPy track works

  • Python playground — lessons use execution_profile: server_script. Every snippet uses import numpy as np; install NumPy locally with pip install numpy if the runner lacks it.
  • Arrays first — creation, dtypes, shape, indexing, ufuncs, broadcasting, linear algebra, and performance—before Pandas labeled tables.
  • Prerequisites — finish Python basics and skim Data Science workflow. Statistics intuition from that track helps.
  • Pair withPandas for DataFrames, SciPy for scientific routines, and AI for ML context.

Run each lesson in the playground, tweak array values, and use MCQs to lock in ndarray vocabulary.

Install on your device (macOS, Linux, Windows)

Install Python 3.11+ locally for notebooks and frameworks; the on-site playground uses the dev runner when enabled.

macOS

  1. brew install python@3.12 or install from python.org (check “Add to PATH” on installers).
  2. Create a project folder: mkdir ~/python-practice && cd ~/python-practice.
  3. python3 -m venv .venv && source .venv/bin/activate
  4. pip install --upgrade pip

Linux

  1. Debian/Ubuntu: sudo apt update && sudo apt install -y python3 python3-pip python3-venv
  2. Fedora: sudo dnf install -y python3 python3-pip
  3. python3 -m venv .venv && source .venv/bin/activate
  4. pip install --upgrade pip

Windows

  1. Install from python.org and enable Add python.exe to PATH.
  2. Or: winget install Python.Python.3.12
  3. PowerShell: py -3 -m venv .venv; .\.venv\Scripts\Activate.ps1
  4. pip install --upgrade pip

Verify: python3 --version (or py --version on Windows) shows 3.11+.

Run code on this site (Backend & language playgrounds)

  1. Clone or open this project locally; copy .env.example to .env.
  2. Ensure LEARNING_RUNNER_ENABLED=true and LEARNING_RUNNER_URL=http://127.0.0.1:9999/v1/execute.
  3. Terminal 1: php artisan serve (or composer run dev for Laravel + Vite + runner together).
  4. Terminal 2: npm run runner — keep it running while you click Run on server.

In your venv: pip install numpy

NumPy provides the ndarray—a fast, homogeneous n-dimensional array—and vectorized operations that power Pandas, SciPy, and most Python ML stacks. This track teaches array thinking after Python basics and alongside Data Science workflow concepts.

Prerequisites and how this track works

Complete Python basics (lists, loops, functions) and skim Data Science intro for workflow context. Lessons run Python with execution_profile: server_script; NumPy is pre-installed in the playground—no pip install needed here.

What you will learn

  • Creating, shaping, and indexing ndarray objects
  • Dtypes, broadcasting, ufuncs, and axis-aware aggregations
  • Linear algebra, fancy indexing, and memory views
  • NaN handling, persistence (.npy), and vectorization habits
  • How NumPy connects to Pandas, Matplotlib, SciPy, and ML libraries

First run

import numpy as np
a = np.array([1, 2, 3, 4, 5])
print('NumPy version:', np.__version__)
print('array:', a)
print('shape:', a.shape, 'dtype:', a.dtype)

Why not plain Python lists?

Lists hold arbitrary objects and loop in Python bytecode. NumPy stores contiguous typed buffers and delegates math to optimized C—often 10–100× faster on large numeric data.

Important interview questions and answers

  1. Q: Is NumPy required for data science?
    A: Not strictly—but Pandas, scikit-learn, and most scientific Python assume NumPy arrays under the hood.
  2. Q: What is an ndarray?
    A: An n-dimensional homogeneous array: fixed dtype, shape tuple, and strided memory layout.

Self-check

  1. Which two tracks should you finish before deep NumPy work?
  2. What does ndarray stand for?

Challenge

First NumPy run in this track

  1. Click Run with the default code.
  2. Confirm the terminal shows array shape and dtype.
  3. Change one element in the sample array and run again.

Done when: the terminal shows ndarray output and your edited value.

Tip: Run the playground challenge—every lesson assumes import numpy as np works.

Interview prep

Prerequisite?

Python basics (/python/intro) and data science workflow (/data-science/intro).

Core type?

ndarray—homogeneous n-dimensional array with shape and dtype.

Next track?

Pandas (/pandas/intro) for labeled tables; SciPy (/scipy/intro) for scientific algorithms.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Why NumPy after Python?
  • ndarray vs list?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump