First, built-in functions
Built-in functions in detail: http://www.runoob.com/python/python-built-in-functions.html
Second, anonymous function
An anonymous function is a specified function that does not need to be displayed
#这段代码def Calc (n): return N**nprint (calc) #换成匿名函数calc = Lambda n:n**nprint (Calc (10))
L=[3,2,100,999,213,1111,31121,333]print (Max (l)) dic={' K1 ': Ten, ' K2 ': +, ' K3 ': 30}print (Max (DIC)) print (Dic[max (DIC, Key=lambda K:dic[k])
# 1 file contents are as follows, title: Name, gender, age, salary # # Egon male 3000# Alex male 30000# Wupeiqi female 20000# Yuanhao female 10000with Open (' B.txt ', encoding= ' utf-8 ') as F: l1=[{' name ': Line.split () [0], ' sex ': Line.split () [1], ' age ': line.split () [2], ' salary ': Line.split () [3]}for line in F] # 4 based on the 1 obtained list, the name of each person in the message is mapped to the first capitalization form l4=[i[' name '] for I in L1] Print (list (map (lambda item:item.capitalize (), L4)) # 5 Filters out the information about the person whose name starts with a, based on the 1 Get list l4=[i[' name '] for i in L1 ] Print (list (filter (lambda name:not name.startswith (' a '), L4)))
Third, recursive call
Recursive properties:
1. There must be a clear end condition
2. Each time a deeper level of recursion is reached, the problem size should be reduced compared to the previous recursion
3. Recursive efficiency is not high, too many recursive hierarchy will lead to stack overflow (in the computer, function calls through the stack (stack) This data structure implementation, each time into a function call, the stack will add a stack of frames, whenever the function returns, the stack will reduce the stack frame. Because the size of the stack is not infinite, there are too many recursive calls, which can cause the stack to overflow.
Recursion has two stages
Stage One: Recursion
Phase II: Backtracking
Python built-in functions, anonymous functions, recursion