Complete the code to create a NumPy array from 0 to 4 using np.arange().
import numpy as np arr = np.arange([1]) print(arr)
np.arange(5) creates an array starting at 0 up to but not including 5, so it includes 0,1,2,3,4.
Complete the code to create a NumPy array from 2 to 6 (excluding 6) using np.arange().
import numpy as np arr = np.arange([1], 6) print(arr)
np.arange(2, 6) creates an array starting at 2 up to but not including 6, so it includes 2,3,4,5.
Fix the error in the code to create an array from 1 to 10 with step 2 using np.arange().
import numpy as np arr = np.arange(1, 10, [1]) print(arr)
The step argument controls the gap between numbers. Step 2 means numbers increase by 2 each time.
Fill both blanks to create an array from 10 down to 2 (excluding 2) with step -2 using np.arange().
import numpy as np arr = np.arange([1], [2], -2) print(arr)
To count down from 10 to 2 (excluding 2) with step -2, start=10 and stop=2.
Fill all three blanks to create a NumPy array of even numbers from 0 to 8 using np.arange().
import numpy as np arr = np.arange([1], [2], [3]) print(arr)
Start at 0, stop before 10, step by 2 to get even numbers 0,2,4,6,8.