0 / 34
Lesson 3

Array Generators

NumPy generators:

np.zeros((2, 3))     # 2ร—3 zeros
np.ones((4,))        # [1. 1. 1. 1.]
np.arange(0, 10, 2)  # [0, 2, 4, 6, 8]
np.linspace(0, 1, 5) # 5 evenly spaced
Why this matters

Real pipelines start with correctly shaped templates (zeros/ones), ranges (arange), or resampled grids (linspace) instead of building lists in Python loops.

Four panels: zeros grid, ones vector, arange step sequence, linspace even points on a line.
Generators encode intent: allocation, counting, or smooth sampling.

Preallocating with zeros/ones is also the usual pattern before filling arrays in numerical code.

ResourcesDocs, references & more โ€” opens in a new tab
๐ŸŽฏ Your Task

Create ramp using np.linspace โ€” 11 values from 0 to 100.

np.linspace(0, 100, 11)
exercise.py
โŒ˜โŽ run ยท โŒ˜โ† โ†’ nav
โ–ถ Output
Run your code to see output here.