Challenge - Nola¶
Make the following 4x7 array called nola that starts with 1 and steps by 2. However, note that the first element in each row is always 4 more than the last element in the previous row.
[[ 1 3 5 7 9 11 13]
[17 19 21 23 25 27 29]
[33 35 37 39 41 43 45]
[49 51 53 55 57 59 61]]
In [1]:
%pip install numpy
import numpy as np
Requirement already satisfied: numpy in /home/samrat/Documents/numpy-torch-tutorials/venv/lib/python3.8/site-packages (1.24.4) Note: you may need to restart the kernel to use updated packages.
In [14]:
np.array([np.linspace(start=i + ((i - 1) * 15), stop=(2*6 + i + ((i - 1) * 15)), num=7) for i in range(1, 5)], dtype=int)
Out[14]:
array([[ 1, 3, 5, 7, 9, 11, 13], [17, 19, 21, 23, 25, 27, 29], [33, 35, 37, 39, 41, 43, 45], [49, 51, 53, 55, 57, 59, 61]])