Python and data for quants
You slice a[::2] and then modify the result. What happens to a?
AppliedMultiple choice
You slice a[::2] and then modify the result. What happens to a?
- AIt changes, because basic slicing returns a view onto the same buffer
- BIt is unaffected, since slicing always copies
- CIt raises an error about writing to a read-only array
- DIt depends on whether the array is contiguous
The worked solution is in Premium
The answer, the full working and the one idea to take away – for this and all 1,322 questions in the bank. Answer it in practice and your working is marked, with a known mistake named when you make one.
Report an issue with this question
Learn the method
Of the kind reported at
More python and data for quants questions
- Shapes in a returns matrix, part 3 of 3Advanced · Premium
- You add an array of shape (100, 5) to one of shape (5,). What happens?Foundation · Premium
- How much memory does a 5,000 × 5,000 float64 NumPy array use, in megabytes?Foundation · Premium
- How many elements does the result of adding NumPy arrays of shapes (3, 1) and (1, 4) have?Foundation · Premium
- What is the length of np.arange(10).reshape(2, 5).sum(axis=0)?Foundation · Premium
- Shapes in a returns matrix, part 1 of 3Foundation · Premium