Back to course home
0% completed
Vote For New Content
Quiz
What is an array in Python?
A
A collection of items stored at contiguous memory locations and accessed via indices.
B
A collection that supports items of mixed data types.
C
A mutable sequence of characters.
D
A key-value store similar to a dictionary.
What will be the output of the following code snippet?
from array import array
arr = array('i', [1, 2, 3, 4, 5])
print(arr[2])
A
1
B
2
C
3
D
4
Why would one use an array instead of a list in Python?
A
Arrays are more memory efficient when storing large quantities of elements of the same data type.
B
Arrays can store elements of different data types.
C
Arrays provide faster access to elements than lists.
D
Arrays support more methods than lists.
What will the following code output?
from array import array
arr = array('i', [1, 2, 3, 4, 5])
del arr[2]
print(arr)
A
[1, 2, 3, 5]
B
[1, 2, 4, 5]
C
[2, 3, 4, 5]
D
Error
What is the purpose of the count() method in array operations?
from array import array
arr = array('i', [1, 2, 2, 3])
result = arr.count(2)
print(result)
A
Counts the number of elements in the array
B
Returns the total sum of all elements
C
Counts how many times an element appears in the array
D
None of the above
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible