First time here? Checkout the FAQ!
x
+1 vote
311 views
asked in Python Interview Questions by (1.4k points)  
  

1 Answer

0 votes
answered by (1.4k points)  

Arrays and Lists, in Python, have the same way of storing data. But, Arrays can hold only a single data type elements whereas Lists can hold any data type elements. 

import array as arr 
My_Array=arr.array('i',[1,2,3,41]) 
My_list=[l,'abc',1.20] 
print(My_Array) 
print(My_list) 

Output:

array('i', [1, 2, 3, 4]) 
[1, 'abc', 1.2] 

In the example above, in My_Array, typecode used is i. This typecode represents signed integer whose size is 2 bytes.

Related questions

...