MindMap Gallery Advanced data types
Advanced data types, such as List: multiple data are packaged and stored into one data type. Identified with [], it supports numbers and strings, and can contain lists (that is, nested). Different types of data items can also appear in the same list. Lists are the most common composite data type in Python.
Edited at 2023-10-31 16:36:57This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
No relevant template
python
Advanced data types
List(list)
Elements in the list are separated by commas
Pack multiple data and store them into one data type. Identified with [], it supports numbers and strings, and can contain lists (that is, nested). Different types of data items can also appear in the same list. Lists are the most common composite data type in Python.
Operator
Splicing
*
repeat
【】
Obtain
【:】
intercept/slice
in
member operator
not in
member operator
function
len(list)
Get the number of elements in the list
list.index(obj)
Get the index of the specified element in the list
list.append(obj)
Add new elements to the end of the list
list.insert(index,obj)
Inserts an element into a list at a specified position
list.extend(seq)
Append multiple values from another sequence at the end of the list (extend the original list with the new list)
list.pop([index=-1])
Removes an element from the list (default is the last element) and returns the value of the element
list.remove(obj)
Removes the first occurrence of an element in a list
list.reverse()
Reverse elements in list
list.sort(key=None,reverse=False)
Sort the original list (only elements of the same type can be sorted, ascending order by default)
Tuple(tuple)
At the time of definition, the elements in the tuple are determined, and elements cannot be appended, inserted, or modified later. Using tuples can make the code safer
An ordered set is similar to a list, except that the elements of a tuple cannot be modified and are marked with ()
#Create an empty tuple
tup2=()
Parentheses () can represent either tuples or parentheses in mathematical formulas. When defining a tuple with only one element, if tup3=(1) is used directly, ambiguity will occur, and the computer will calculate according to the parentheses. , the result returned by tup3 is the number 1
#Create a tuple with only one element
tup3=(1, )
A comma must be added when defining a 1-element tuple to eliminate ambiguity. Similarly, Python will also add a comma when displaying a tuple with only 1 element.
Dictionary(dict, dictionary)
Dictionary keys and values are separated by colons
Identified with {} and using key-value (key-value) storage, it is equivalent to saving two sets of data. One set of data is key data and is called key; the other set of data can be accessed through key and is called value. . There is a one-to-one correspondence between key and value
Commonly used functions
Dictionaries are not sequences, so operations such as splicing and interception cannot be performed on dictionaries.
dict[key]
Access values in a dictionary
dict[key]=
Modify value
dict[key]=
Add key-value pairs
del dict[key]
Delete key-value pair
del dict
delete dictionary
dict.keys()
Return all keys as a list
dict.values()
Return all values as a list
dict.items()
Return all key-value pairs
Set(set)
When creating a collection, if duplicate elements are passed in, they will be automatically filtered.
Similar to a dictionary, it is a collection of keys, but does not store values. Since keys cannot be repeated, there are no duplicate keys in the collection. The collection can be regarded as a collection of unordered and non-repeating elements in the mathematical sense. The collection uses { }identification
Commonly used functions
set.add(key)
Add element
set.remove(key)
Delete element