What are tuples and collections in python
This article focuses on "what are tuples and collections in python". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what tuples and collections are in python.
One, tuple tuple
Tuple is an ordered data structure, similar to list, but its content cannot be changed.
Compared with list, the data stored in tuple is more secure because it is immutable.
It is common to use tuple to assign values to multiple variables in python.
Two, gather set
A collection is an unordered data structure that can be thought of as a dictionary with only key.
Like key in the dictionary, the elements of the collection must be immutable data types, such as str,int,float,tuple, and so on, not mutable data types such as list,set,dict.
Set is often used in python to realize the algorithms of removing repetitive elements, finding intersection, union, complement and so on.
Third, thinking practice
11A = 2; b = 3; how to use tuple's feature of assigning values to multiple variables to interchange the values of an and b with one statement? (reply keyword python11 for reference answer)
At this point, I believe you have a deeper understanding of "what are tuples and collections in python". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!