One of the most common Python interview question. In Python, both arrays and lists are used to store data. However,
Arrays can only contain elements of the same data types, meaning the data types of an array should be homogeneous.
Lists can contain elements of different data types, which means that the data types of lists can be heterogeneous. Lists consume much more memory than arrays.
Here’s an example:
import array as arr
My_Array=arr.array(‘i’,[1,2,3,4])
My_list=[1,’abc’,1.20]
print(My_Array)
print(My_list)