</>
Topic 1 of 3
Theory

Arrays

numpy works with arrays — grids of numbers of the same type. Its superpower: an operation applies to every element at once, no loops needed.

import numpy as np

a = np.array([1, 2, 3])
print(a * 10)        # [10 20 30]
print(a + a)         # [2 4 6]
print(a.min(), a.max(), a.mean())

The first run downloads numpy — it takes a few seconds.

Double it

Easy+10 XP

Return an array where every element of arr is multiplied by 2. No loops.

double(np.array([1, 2, 3])) → [2 4 6]
main.pyLoading Python, numpy…
Output
Press "Check" to run the tests