S30 Logo
S30 AI Labwww.thes30.com
Back
#1

NumPy Lab

Easy🐍 Python & DataW1 D2

NumPy Lab

Build deep intuition for NumPy internals, vectorization, and performance — the way FAANG expects ML engineers to think.

You can write fast, memory-efficient, interview-ready NumPy code and explain *why* it is efficient.

Progress — 0/26 tasks

1Tasks
2ndarray Fundamentals
3dtype & Memory
4Indexing, Views & Copies
5Boolean Masking
6Broadcasting
7Broadcasting Trap
8Vectorization vs Loops
9Numerical Stability
10Linear Algebra
11Performance & Memory
12Mini Case Study
Python 3 — Notebook
1
Dataset & Setup

Setup

Section 1 — ndarray Fundamentals

Task 1.1: Array Creation & Shapes

Loading editor...
1

ndarray Fundamentals

2
Array Creation & Shapes

Create a 1D array with values 0 to 99 (no loops)

Loading editor...
3
Array Creation & Shapes

Reshape arr_1d into a (10, 10) array

Loading editor...
4
Array Creation & Shapes

Create a 3D array of shape (4, 5, 3)

Loading editor...
2

dtype & Memory

5
Create two arrays with same values but different dtypes

Create two arrays with same values but different dtypes

Loading editor...
6
Compare memory usage

Compare memory usage

Loading editor...
3

Indexing, Views & Copies

7
Views vs Copies

Create a 2D array and slice every alternate row

Loading editor...
8
Views vs Copies

Modify A_slice and observe A

Loading editor...
4

Boolean Masking

9
Create random array of size 1000

Create random array of size 1000

Loading editor...
10
Extract values greater than mean

Extract values greater than mean

Loading editor...
11
Replace negative values with 0 (no loops)

Replace negative values with 0 (no loops)

Loading editor...
5

Broadcasting

12
Broadcasting Rules

Create A (1000, 50) and b (50,)

Loading editor...
13
Broadcasting Rules

Add b to each row of A

Loading editor...
14
Broadcasting Rules

Normalize each row of A

Loading editor...
6

Broadcasting Trap

15
Intentionally trigger a broadcasting error

Intentionally trigger a broadcasting error Then fix it

Loading editor...
7

Vectorization vs Loops

16
Loop vs Vectorized

Create large array X of size 1,000,000

Loading editor...
17
Loop vs Vectorized

Normalize using Python loop

Loading editor...
18
Loop vs Vectorized

Normalize using vectorization

Loading editor...
19
Pairwise Distance (FAANG Classic)

Compute pairwise Euclidean distance matrix without loops

Loading editor...
8

Numerical Stability

20
Softmax

Implement naive softmax

Loading editor...
21
Softmax

Fix numerical instability

Loading editor...
9

Linear Algebra

22
Matrix Multiplication

Try valid and invalid matrix multiplications

Loading editor...
23
Solving Linear Systems

Solve Ax = b and verify solution

Loading editor...
10

Performance & Memory

24
In-Place Operations

Compare in-place vs out-of-place operations

Loading editor...
25
Strides

Inspect array strides and explain

Loading editor...
11

Mini Case Study

26
Given X (10000, 100):

Given X (10000, 100):

Loading editor...