Python Programming - Arrays
Exercise : Arrays - General Questions
- Arrays - General Questions
61.
What is the result of the expression
np.linspace(0, 1, 5, endpoint=False)?
Answer: Option
Explanation:
The expression generates an array with values from 0.0 to 1.0 (exclusive) with a step of 0.2 and excludes the endpoint.
62.
Given a NumPy array
arr = np.array([[1, 2, 3], [4, 5, 6]]), what does arr.shape return?
Answer: Option
Explanation:
The
arr.shape attribute returns the dimensions of the array.
63.
How can you create a NumPy array filled with zeros of shape (4, 4)?
Answer: Option
Explanation:
The
np.zeros() function creates an array filled with zeros of the specified shape.
64.
How do you reshape a NumPy array
arr into a single-dimensional array?
Answer: Option
Explanation:
The
arr.ravel() function flattens the array into a single-dimensional array.
65.
What is the purpose of the NumPy function
numpy.vstack((arr1, arr2))?
Answer: Option
Explanation:
The
numpy.vstack() function stacks the arrays vertically.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers