Python Programming - Arrays
Exercise : Arrays - General Questions
- Arrays - General Questions
11.
What is the purpose of the
numpy.shape
attribute in a NumPy array?
Answer: Option
Explanation:
The
numpy.shape
attribute returns a tuple representing the dimensions of the NumPy array.
12.
How do you perform element-wise addition of two NumPy arrays,
arr1
and arr2
?
Answer: Option
Explanation:
The
+
operator can be used for element-wise addition of two NumPy arrays.
13.
What is the purpose of the
numpy.flatten()
method?
Answer: Option
Explanation:
The
numpy.flatten()
method flattens the array, converting it to a one-dimensional list.
14.
How do you initialize an array with five zeros using the
array
module?
Answer: Option
Explanation:
The correct way to initialize an array with five zeros using the
array
module is array.array('i', [0, 0, 0, 0, 0])
.
15.
What is the purpose of the
array.remove(element)
method in the array
module?
Answer: Option
Explanation:
The
remove()
method in the array
module removes the first occurrence of the specified element from the array.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers