Python Programming - Arrays
Exercise : Arrays - General Questions
- Arrays - General Questions
81.
What does the NumPy function
numpy.zeros((2, 3))
return?
Answer: Option
Explanation:
The
numpy.zeros()
function creates an array filled with zeros of the specified shape.
82.
How can you reverse the order of elements along the first axis of a NumPy array
arr
?
Answer: Option
Explanation:
The
np.flip()
function can be used to reverse the order of elements along a specified axis.
83.
Given a NumPy array
arr = np.array([[1, 2], [3, 4]])
, what does arr.sum(axis=1)
calculate?
Answer: Option
Explanation:
The
sum()
function with axis=1
calculates the sum of elements in each row.
84.
Given a NumPy array
arr = np.array([[1, 2, 3], [4, 5, 6]])
, how can you extract the second column?
Answer: Option
Explanation:
The colon
:
denotes all rows, and 1
specifies the second column.
85.
What does the NumPy function
numpy.vstack((arr1, arr2))
do?
Answer: Option
Explanation:
The
numpy.vstack()
function vertically stacks arrays.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers