Python Programming - Arrays
Exercise : Arrays - General Questions
- Arrays - General Questions
6.
What is the primary difference between a list and an array?
Answer: Option
Explanation:
Arrays in Python can be multi-dimensional, allowing for the storage of data in multiple dimensions, while lists are one-dimensional.
7.
What does the
array.append(element) method do?
Answer: Option
Explanation:
The
append() method in the array module adds an element to the end of the array.
8.
How do you access the element at index 2 in a one-dimensional array named
arr?
Answer: Option
Explanation:
In Python arrays, elements can be accessed using square brackets and the index, like
arr[index].
9.
Which of the following statements about NumPy arrays in Python is true?
Answer: Option
Explanation:
NumPy arrays in Python support element-wise operations, making them efficient for mathematical computations.
10.
How do you create a 2D NumPy array?
Answer: Option
Explanation:
The correct syntax to create a 2D NumPy array is
np.array([[1, 2, 3], [4, 5, 6]]).
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers