0 / 34
Lesson 10

Universal Functions

Element-wise math functions:

np.sin(a)  np.exp(a)  np.sqrt(a)  np.abs(a)
Why this matters

Universal functions (ufuncs) apply sin, exp, log, etc. to entire arrays as fast C loops. They are the building blocks of physics, finance, and ML transforms (activations, losses, feature scaling).

Composing ufuncs is how you keep numerical code expressive without dropping to element-wise Python.

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

Create angles = [0, ฯ€/6, ฯ€/4, ฯ€/3, ฯ€/2]. Compute sines = np.sin(angles). Print rounded to 2.

np.array([0, np.pi/6, np.pi/4, np.pi/3, np.pi/2])
exercise.py
โŒ˜โŽ run ยท โŒ˜โ† โ†’ nav
โ–ถ Output
Run your code to see output here.