ArrayLab Explore arrays. Understand tensors.
a = shape (5,)
Try

Spaces or commas between values · new line = new row · blank line = new 2-D layer (3-D array).

Operation on each element x
Starting Python… (first visit downloads ≈ 15 MB, then it is cached)
Python not started
import numpy as np

a = np.array([1, 2, 3, 4, 5])

# Python loop: one element at a time
out = []
for x in a.ravel():
    out.append(x * 2)
loop_result = np.array(out).reshape(a.shape)

# Vectorized: one expression for the whole array
vec_result = a * 2

np.array_equal(loop_result, vec_result)
Output

Output appears here.