Collections and Arrays Worksheets
Collections and Arrays Worksheets
CHAPTER – 6
UNDERSTANDING ARRAYS
WORKSHEET
1. The __________ method is used to remove the last element from an array in Python.
2. To find the position of an element in an array, you can use the __________ method.
3. The __________ function returns a new array that is a sorted version of the original
array, without modifying it.
4. To check if an element exists in an array, you can use the __________ operator.
5. The __________ sort is a simple comparison-based sorting algorithm that repeatedly
steps through the list, compares adjacent elements, and swaps them if they are in the
wrong order.
4. Given the array arr = [3, 6, 8, 12], what will arr.index(8) return?
a) 1 c) 3
b) 2 d) Error
5. In Python, the ‘in’ operator is used to __________.
a) Insert an element in the array
b) Check if an element exists in the array
c) Sort the array
d) Remove an element from the array
Part C: Programming Questions
1. Sorting an Array:
Write a Python program to sort the array [45, 12, 89, 33, 7] in ascending order.
arr = [45, 12, 89, 33, 7]
___________________
print(arr)