Skip to content
Learn Netverks

Lesson

Step 10/36 28% through track

array-math

Array math

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

This lesson

This lesson teaches Array math: NumPy ndarray operations, vectorization, and numerical patterns used across the Python scientific stack.

Teams apply Array math in every serious NumPy project—skipping it leaves blind spots in analysis and reviews.

You will apply Array math 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.

When you can explain the previous lesson's ideas in your own words.

Element-wise arithmetic works between same-shaped arrays or scalars: +, -, *, /, **. Matrix multiplication uses @ or np.dot—covered later.

Element-wise operations

import numpy as np
a = np.array([1, 2, 3])
b = np.array([10, 20, 30])
print(a + b, a * 2, b / a)

Comparison and logical

  • arr > 0 — boolean array
  • np.abs, np.sqrt, np.exp — ufuncs
  • np.where(cond, x, y) — element-wise choice

In-place operators

+=, *= modify arrays in place—useful but dangerous if the array is a view shared elsewhere.

Important interview questions and answers

  1. Q: a * b vs a @ b?
    A: Star is element-wise multiply; @ is matrix multiplication (linear algebra).
  2. Q: Scalar broadcast?
    A: Adding scalar to array applies to every element without copying the scalar N times.

Self-check

  1. Compute element-wise square of an array.
  2. What ufunc gives absolute values?

Tip: Remember * is element-wise; @ is matrix multiply.

Interview prep

* vs @?

Star element-wise; @ matrix multiplication.

Scalar broadcast?

Scalar ops apply to every element without explicit replication.

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

  • Element-wise vs dot?
  • In-place += risk?

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