Bubbling algorithm: For the sequence to be sorted, compare two elements at a time, and if the sort is wrong, swap the two until the sorting is complete.Take the series Li = [12,22,3,11,8,10] as an example:For M in range (Len (LI)-1): For n in
1.print and Import1.1 Print slightly1.2 Import(1) Impore Somemodule (2) from Somemodule import somefunction(3) from Somemodule import somefunction,anotherfunction(4) from Somemodule import*(5) Import somemodule as Somename #为整个模块提供别名(6) From
First, the derivation of the formula(i). List derivation (set deduction also applies to this)Use list derivation to remove all even numbers within 1-20Li = [i for I in range (1, +) if I% 2 = = 0] # If there is only one condition, write the IF
Multi-threading and multi-process usage scenariosIo operation does not consume CPU (from hard disk, from network, read data from memory to count IO)Calculate CPU usage (e.g. COMPUTE)A thread in Python is a dummy thread, and switching between
Sorting algorithms can be divided into internal and external sorting, the internal sorting is the data records in memory to sort, and the external sort is because of the data is very large, one can not hold all the sort records, in order to access
I. Deep copy and shallow copy1. Referencing and assigning valuesA reference is a value that points to some dataA list reference is a value that points to a listWhen you assign a list to a variable, you actually assign the ' reference ' of the list
1 Basic implementationsThread (target= function name, args= (argument passed as tuple, add ","))th = Threading. Thread (target=run,args= (i,)) is the instantiation of a threadTh.start () is the start function called on the instance.Internally, the
What if I now have a list of l=[' A ', ' B ', ' C ', ' d ', ' e ', and I want to fetch the contents of the list in several ways?First, I can index the value of l[0], and then we can also use for the loop to take the value ah?Have you ever thought
IteratorsWe already know that there are several types of numbers that can directly act on a For loop:
A type is a collection of types: list, tuple, dict, set, str, bytes, and so on.
The other category is generator, which includes
A connected graph may have multiple spanning trees, and the minimum spanning tree is a spanning tree with the least weight in a connected weighted undirected graph, which can be derived from the prim algorithm and the Kruskal algorithm, which are
Use for statementExample 6.3 uses a for statement
The code is as follows
Copy Code
#!/usr/bin/python# Filename:for.pyFor I in range (1, 5):Print IElseprint ' For loop are over 'Output$ python for.py1234The For loop are
Do not use a Mutable object as the default value of a function
Copy Code code as follows:
In [1]: def append_to_list (value, def_list=[]):
...: def_list.append (value)
...: Return Def_list
...:
In [2]: My_list =
In calculating the time complexity of the algorithm, we generally adopt the Bigo function. The Bigo function retains only the most valuable function components, removing the coefficients and removing the constants. For example: O (a*n^2+b*n+1) =o (n^
Preface: Diagram of Threads and processes
From the point of view, in each application execution process, will produce a master process and the main thread to complete the work, when we need concurrent execution, it will be through the main process
1. Movement Rate
In the previous section, a car was implemented on the road from bottom to top, and Pygame.time.delay (200) was used to delay the time. Read a lot of reference materials, basic each material will talk about the different
The derivation is a very powerful and popular feature in Python, with the advantages of simple language and fast speed. The derivation formula includes:
1. List-derived2. Dictionary derivation formula3. Set Deduction formula
Nested-List
Queue-dequeWith the basics of the above section, of course you need to fully master all the methods in the previous section, because the methods in the previous section, in the following tutorialwill be used over and over again.If you do not
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.