Commonly used composite data types in Python
List: Use ' [] ' to create, such as ["Hello", "World", "Hello", "Python"], the list is a Mutable object, supporting the original modification (that is, it can be directly in memory in place to make changes), support for the data itself to make changes (see Figure 1)
Tuples: Using ' () ' to create, such as (' Hello ', ' world '), tuples are immutable objects
String: The string is also a sequence type, and the string can be sliced and referenced (see Figure 2), note: The slice itself is creating a new object because the string is immutable, so the sliced slice is a new object.
In fact, lists and tuples do not really store data, but rather hold object references.
is: Determines whether the left-side object reference is the same Yu Yu-side object reference;
In, not in: testing member relationships
Python Control flow statement
If: conditional judgment, can be a single branch, two branches, multiple branches, in Python branches need to add ': ' number
While
For ... in
Try: Do an exception capture
Python arithmetic operators
Provides a complete set of arithmetic operations in Python, a lot of Python data types can also use enhanced assignment operators, such as + +, =, *=,%, and so on; the performance of the enhanced assignment operator is better than the agreed function; because Python's int type is immutable objects, So the actual process of an enhanced assignment is to create a new object to store the result and then rebind the variable name