What is the output of the following NumPy code snippet?
import numpy as np
arr = np.arange(9).reshape(3, 3)
arr_flatten = arr.flatten()
arr_flatten[0] = 99
print(arr)
Correct answer
A. [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
14 views
import numpy as np
arr = np.arange(9).reshape(3, 3)
arr_flatten = arr.flatten()
arr_flatten[0] = 99
print(arr)
A. [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
14 views
The flatten() function returns a copy of the array collapsed into one dimension, modifying it does not affect the original array
Not sure why the answer is A? Ask here and get an explanation.