Python Programming - Arrays
Exercise : Arrays - General Questions
- Arrays - General Questions
41.
How do you find the median value of a NumPy array
arr
?
Answer: Option
Explanation:
The
np.median()
function calculates the median value of the array.
42.
What does the NumPy function
numpy.zeros((3, 4))
do?
Answer: Option
Explanation:
The
numpy.zeros()
function creates a 3x4 array with all elements initialized to zero.
43.
How can you find the indices of non-zero elements in a NumPy array
arr
?
Answer: Option
Explanation:
The
np.nonzero()
function returns the indices of non-zero elements in the array.
44.
What does the NumPy function
numpy.linspace(1, 10, 5)
do?
Answer: Option
Explanation:
The
numpy.linspace()
function generates a sequence of 5 evenly spaced values between 1 and 10.
45.
Given a NumPy array
arr = np.array([2, 4, 6, 8, 10])
, how do you extract elements at even indices?
Answer: Option
Explanation:
The code
arr[::2]
extracts elements at even indices from the array.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers