1. What is the difference between a list, a tuple, a dictionary?
The ① list is the brackets [], the tuples are parentheses (), the dictionary is curly braces {}
② lists are ordered, tuples are ordered, dictionaries are unordered
The ③ list stores values, tuples are values, dictionaries are key-value pairs (key\value)
The ④ list is mutable, the tuple is immutable, and the dictionary is mutable.
On an application, tuples are compared to lists:
A. Faster than List operation
B. ' Write-protect ' of data
C. Can be used in string formatting
D. A key that can be used as a dictionary
A dictionary is a way of exchanging space for time, compared to a dictionary:
A. The search and insertion of dictionaries is very fast and does not increase with the key value
B. Dictionaries require a lot of memory, and memory waste is much
C. The lookup time of a list increases as the element increases
D. Small footprint, Little wasted memory
------Set Collection: The only difference between a ① and a dictionary is that there is no store value for the corresponding
② Create a set, you need to provide a list as an input collection
③ because set has the ability to automatically remove duplicate elements, its elements must be immutable, since it is not possible to determine whether two mutable objects are equal
Python Learning--day1 (list, tuple, dictionary differences)