Skip to content
Learn Netverks

Lesson

Step 5/36 14% through track

numpy-workflow

NumPy workflow

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

This lesson

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

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

You will apply NumPy workflow 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 print `.shape` and `.dtype` after every new array you create.

At the start of the track—complete before lessons that assume ndarray, dtype, and shape vocabulary.

A repeatable NumPy workflow: createinspect (shape, dtype) → transform (vectorized) → aggregatevalidate → hand off to Pandas or ML.

Inspect first

  • arr.shape — dimensions
  • arr.dtype — element type
  • arr.ndim — number of axes
  • arr.size — total element count

Shape bugs cause silent wrong answers—always print shape before heavy math.

Prefer vectorization

Replace Python loops with ufuncs and axis parameters. Loops on large arrays are a performance smell.

Reproducible randomness

import numpy as np
rng = np.random.default_rng(42)
sample = rng.normal(0, 1, size=5)
print(sample)

Next steps in this track

Modules 02–05 cover creation through advanced memory. Module 06 previews Pandas and SciPy; module 07 prepares interviews and production habits.

Important interview questions and answers

  1. Q: Why print shape?
    A: Catches dimension mismatches before broadcasting or matmul errors.
  2. Q: default_rng vs legacy random?
    A: NumPy recommends Generator API (default_rng) for better statistical properties.

Self-check

  1. List four inspect attributes for any ndarray.
  2. What is the recommended random API in modern NumPy?

Challenge

Set RNG seed

  1. Run the workflow lesson code.
  2. Re-run with a different default_rng seed and compare output.

Done when: you understand reproducible random arrays.

Interview prep

Inspect first?

Print shape, dtype, ndim before transforms—catches silent bugs.

RNG?

Use np.random.default_rng(seed) for reproducible experiments.

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

  • Check shape habit?
  • dtype first why?

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