Home  >  Article  >  Backend Development  >  Is an array a collection in python?

Is an array a collection in python?

anonymity
anonymityOriginal
2019-06-14 16:01:243304browse

There is no concept of array in Python. Array is a data structure. A collection is a data structure that contains a set of elements.

Is an array a collection in python?

Summary of data structures in Python:

In Python there are only tuples and lists;

Once a tuple is created, it cannot be changed, for example: aa=tuple(1,2,3);

Tuples cannot append (append) elements or pop (pop) Elements, etc.;

Only the elements in the tuple can be indexed aa[0], and the tuples therein cannot be assigned aa[0]=8;

The advantage of using tuples is that operating on tuples is more efficient and suitable for storing a set of constants;

While many of the above are not possible, it is possible to use a list.

For arrays:

list: array

tuple: read-only array

dict: dictionary

set: Set (can be regarded as a set in a mathematical sense)

The above is the detailed content of Is an array a collection in python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn