692 views

1 Answer

0 0 votes

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

0 0 votes
1 1 answer
688
688 views
1 1 vote
1 1 answer
873
873 views
1 1 vote
1 1 answer
1.1k
1.1k views
1 1 vote
1 1 answer
702
702 views
askpython asked Jul 9, 2019
702 views
1 1 vote
1 1 answer
614
614 views
askpython asked Jul 9, 2019
614 views