• Register
110 points
5

Overview list & Array

Today we will see in our website kodlogs what is the difference between array and list in Python. Is this list exactly like array. What we have read in C ++ and Java actually means array and list in programming.  The only difference is that in C ++ and c # and Java we can store the same data type. It can be in data integers and floats and strings. And in the list of Python.  Anyone can store any data. That is, we can store anything in Python. If we have to do calculations in data science, then we have to use a numpy array in Python. Python has flexibility.  I don't have to use a normal array.

Difference between List and Array

List

Greater flexibility, preferred for shorter Sequence of data item,consume larger memory for easy addition of elements. Different date type. 

Array

Less flexibility, preferred for longer sequence of data item.comparatively more compact in memory size.similar Datatype.

Example 1

List >>>[2,3.6,"k",3]

Array>>[1,2,3,4,5]

Example 2

Simple_list=[2,"kodlogs",['k','t']]
Print(sample-list)

OUTPUT 

[2,'Kodlogs ',['k','t'] ]

Example 3

Import array
Sample _array=array.array('i',[4,5,6])
     For i in sample_array:
      Print (i)

OUTPUT 

4
5
6

 

110 points
5