1. Recursion
def test1 (): num =int (input ( " Enter number " Span style= "color: #000000")) if num%2==0: # return True # is even, program exits, returns true print (" Not even please reenter " ) return Test1 () # Not even then continue calling yourself, enter a value print (Test1 ())
Recursive efficiency is not high, the maximum recursion 999 times
2. Built-in functions
Python's own function
ID () #看内存地址
type () #看数据类型
print () #打印
input () #输入
list () #转list
set () #转集合
str () #转字符串
dict () #转字典
int () #转int
float () #转float
Len () #字符串长度
Print (All ([1,2,3,4])) #判断可迭代的对象里面的值是否都为真
print (Any ([0,1,2,3,4])) #判断可迭代的对象里面的值是否有一个为真
print (BIN) #十进制转二进制
Print (bool (' s ')) #把一个对象转换成布尔类型 (non-null-true, not 0-true)
print (CHR) #打印数字对应的ascii
Print (ord (' B ')) #打印字符串对应的ascii码
EXEC () #执行括号内的代码
d={}print (dir (d))# to print callable methods of incoming objects
A=eval ('1+2')print(a) # executes Python code, only executes some simple code, such as arithmetic
Print (filter (lambda x:x>5,[12,3,12,2,1,2,35)) #把后面的迭代对象根据前面的方法筛选
Print (Map (lambda x:x>5,[1,2,3,4,5,6))
Print (max (111,12)) #取最大值
Print (Round (11.1123,2)) #取几位小数
Print (sorted ([2,31,34,6,1,23,4])) #排序
Python Learning (16) built-in functions, recursive