Python Programming - Arrays
Exercise : Arrays - General Questions
- Arrays - General Questions
86.
What does the NumPy function
numpy.identity(3) generate?
Answer: Option
Explanation:
The
numpy.identity() function generates an identity matrix with ones on the main diagonal.
87.
How can you flatten a NumPy array
arr in column-major order?
Answer: Option
Explanation:
The
ravel() function with order='F' flattens the array in column-major order.
88.
Given a NumPy array
arr = np.array([10, 20, 30, 40]), what does arr[1:3] return?
Answer: Option
Explanation:
The slice
arr[1:3] extracts elements from index 1 to (3-1).
89.
How can you reshape a NumPy array
arr to have 2 rows and 3 columns?
Answer: Option
Explanation:
The
reshape() function is used to reshape the array.
90.
What is the result of the expression
np.linspace(0, 1, num=5, endpoint=False)?
Answer: Option
Explanation:
The
np.linspace() function generates evenly spaced numbers over a specified range.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers