Recall & Review
beginner
What does the
numpy.array() function do?It creates a new array from a list or sequence of numbers. This array can be used for fast math and data operations.
Click to reveal answer
beginner
How does
numpy.arange() differ from Python's built-in range()?numpy.arange() can create arrays with decimal steps, not just whole numbers like range(). It returns a NumPy array instead of a list.Click to reveal answer
beginner
What is the purpose of
numpy.linspace()?It creates an array of evenly spaced numbers between a start and stop value, including the stop value. You specify how many numbers you want.
Click to reveal answer
intermediate
Example: What does
np.arange(1, 5, 0.5) produce?It creates an array starting at 1, increasing by 0.5, up to but not including 5: [1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5]
Click to reveal answer
intermediate
Why might you choose
linspace() over arange()?Because
linspace() lets you specify the exact number of points you want between start and stop, which is helpful for precise spacing. arange() uses step size, which can cause rounding issues.Click to reveal answer
Which function creates an array with a specific number of evenly spaced points between two values?
✗ Incorrect
numpy.linspace() creates a fixed number of points evenly spaced between start and stop.What will
np.arange(0, 3, 1) output?✗ Incorrect
np.arange() includes start but excludes stop, so it stops before 3.Which function converts a Python list into a NumPy array?
✗ Incorrect
numpy.array() takes a list and returns a NumPy array.If you want 5 numbers evenly spaced from 0 to 1, which function and parameters would you use?
✗ Incorrect
np.linspace(0, 1, 5) creates exactly 5 points evenly spaced between 0 and 1.What type of object do
numpy.array(), arange(), and linspace() return?✗ Incorrect
All these functions return a NumPy array, which is optimized for math and data tasks.
Explain how to create a NumPy array from a Python list and why you might want to do this.
Think about turning simple lists into powerful arrays for calculations.
You got /4 concepts.
Describe the difference between
arange() and linspace() and when to use each.Focus on how you control the spacing and number of points.
You got /5 concepts.