1. Write a python program to add on one number into the following array, array_a
The output is:
array_a = array('i', [1, 2, 3, 4, 5])
Expected Answer:
Initial array: array('i', [1, 2, 3, 4, 5])
Append 6 at the end of the array:
New array: array('i', [1, 2, 3, 4, 5, 6])
2. Write a python program to reserve the sequence of the items in the arrays, array_a as provided in the following output.
The output is:
array_a = array('i', [1, 2, 3, 4, 5])
Expected Answer:
The initial array: array('b', [1, 2, 3, 4, 5])
After reversing the array: array('b', [5, 4, 3, 2, 1])
3. Write a python program to access the last three items in the arrays, array_a as provided in the following output.
The output is:
array_a = array('b', [1, 2, 3, 4, 5])
Expected Answer:
The initial array:
1
2
3
4
5
Access last three items individually
3
4
5
4. Write a python program to remove the specified item from the initial arrays, array_a as provided in the following output.
The output is:
array_a = array('b', [0, 1, 2, 3, 4, 5])
remove number: 2
Expected Answer:
The initial array: array('b', [0, 1, 2, 3, 4, 5])
Remove the number '2' from the initial array:
New array: array('b', [0, 1, 3, 4, 5])
5. Write a python program to obtain the length in bytes of one arrays, array_a as provided in the following output.
The output is:
array_a = array('b', [0, 1, 2, 3, 4, 5])
Expected Answer:
The initial array: array('b', [0, 1, 2, 3, 4, 5])
The length in bytes of one array item: 1
6. Write a python program to add a list_a as provided in the following output into an empty arrays, array_a .
The output is:
list_a = [0, 1, 2, 3, 4, 5]
Expected Answer:
The initial elements in the list: [0, 1, 2, 3, 4, 5]
New array is: array('b', [0, 1, 2, 3, 4, 5])
The class of array_b is: [class 'array.array']
7. Write a python program to check the quantity of occurrences of a specified values in the array_a as provided in the following output.
The output is:
array_a = array('b', [0, 1, 2, 3, 4, 5, 7, 8, 5, 9, 10, 5])
Expected Answer:
The initial array: array('b', [0, 1, 2, 3, 4, 5, 7, 8, 5, 9, 10, 5])
Quantity of occurrences for number 5 in the array_a: 3
8. Write a python program to insert a new number before a specified element of array_a as provided in the following output.
The output is:
array_a = array('i', [0, 1, 2, 3, 4, 5, 7, 8, 5, 9, 10, 5])
new number: 8
insert the new number before number: 6
Expected Answer:
The initial array: array('b', [0, 1, 2, 3, 4, 5])
Insert new value 8 before number 5:
New array: array('b', [0, 1, 2, 3, 4, 8, 5])
9. Write a python program to add in another set of array_a into the initial array_a as provided in the following output.
The output is:
array_a = array('b', [0, 1, 2, 3, 4, 5])
Expected Answer:
The initial array: array('b', [0, 1, 2, 3, 4, 5])
The new array: array('b', [0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5])
10. Write a python program to remove the first occurrence of number 1 in the array_a as provided in the following output.
The output is:
array_a = array('b', [0, 1, 2, 3, 4, 5, 2, 1, 5])
Expected Answer:
The initial array: array('b', [0, 1, 2, 3, 4, 5, 2, 1, 5])
Remove the first occurrence of number 1 from the array_a: array('b', [0, 2, 3, 4, 5, 2, 1, 5])
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)