Built-in functions: ABS () for absolute use: deal with left and right problems, coordinates,
Max () max (12,13,14) ——— min () min () min (9,8,7)---->7
POW () 5,3----->5 three round () rounding round (3.6)---->4 round (4.5)--->4 comment (bug): If 4.5,6.5,8.5 .... (The integer part), the odd number can be entered, the even number cannot enter
SUM () sum--------sum ([1, 2, 3])
Module : (Package, namespace) when you need to import the-------"Imports module name Why use : In more than one PY file will appear the same name (variables, functions, classes) in order not to let the name conflict the different py files in different folders Math.ceil (3.9) #向上取整Math.floor (3.9) #向下取整 math.sqrt (+) #平方根 math.modf (3.14) #返回小数和整数部分 Math.PI #- ----"3.141592653589793
Random number module : Random
Random.random ()---> #随机0-1 digit (decimal) less than 1
Random.randint (1, 3)----#随机1-3 integer can be taken to the maximum value
Random.randrange (1, 3)----#随机1-3 integer, without maximum value
Random.randrange (2)----#只写一个默认从0开始到这个数字, maximum value not being taken
Random.randrange (1,10,2)----"#2是步长
Random.uniform (1, 3)----"#随机1-3 decimals
Random.choice (["A", "B", 1, 2])-----"#随机列表中的一个数据
Random.sample (["A", "B", 1, 2], 2)-----"#随机列表中指定的几个数据
li=[1,2,3,4,5]--"random.shuffle (LI)---"# to scramble the data in the list
Random.choice ("abcd1234")----"#从字符串中随机取一个字符
Python Foundation fourth day