Complete the code to create an array of 5 numbers evenly spaced between 0 and 10.
import numpy as np arr = np.linspace(0, 10, [1]) print(arr)
The third argument in np.linspace() specifies how many numbers to generate. Here, 5 numbers between 0 and 10 are created.
Complete the code to create 4 numbers evenly spaced between 1 and 2.
import numpy as np arr = np.linspace(1, [1], 4) print(arr)
The second argument is the end value. Here, 4 numbers between 1 and 2 are created.
Fix the error in the code to generate 6 numbers from 0 to 5.
import numpy as np arr = np.linspace(0, 5, [1]) print(arr)
The third argument must be 6 to get six numbers including both 0 and 5.
Fill both blanks to create an array of 7 numbers from 10 to 20.
import numpy as np arr = np.linspace([1], [2], 7) print(arr)
The first blank is the start (10), the second blank is the end (20), and 7 numbers are generated between them.
Fill all three blanks to create a dictionary with keys as numbers from 1 to 5 and values as their squares using np.linspace().
import numpy as np numbers = np.linspace([1], [2], [3]) squares = {int(num): int(num)**2 for num in numbers} print(squares)
The numbers start at 1, end at 5, and there are 5 points to get integers 1 to 5. The dictionary comprehension creates squares.