निम्नलिखित कोड का उद्देश्य क्या है?
What is the purpose of the following code ?
import numpy as np
z=[1,2,3]
y=np.array(z) A
to convert z to array
B
to convert z to list
C
Both of the above
D
None of the above
Explanation
The code provided:
import numpy as np
z = [1, 2, 3]
y = np.array(z)
Explanation:
z = [1, 2, 3]: This creates a regular Python list with elements 1, 2, and 3.y = np.array(z): This converts the Python listzinto a NumPy array and stores it iny.
Thus, the purpose of the code is to convert the list z into a NumPy array.
Answer: (A) to convert z to array
Correct Answer: A) to convert z to array