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']
Sample Answer:
from array import * list_a = [0, 1, 2, 3, 4, 5] array_b = array('b', []) print("The initial elements in the list: " + str(list_a)) array_b.fromlist(list_a) print("New array is: "+ str(array_b)) print("The class of array_b is:",type(array_b))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)