Reference text:
Http://www.liaoxuefeng.com
1. Functions
(1) Python's commonly used built-in functions:
A. Absolute value return function: ABS (x)
B. Comparison function: cmp (x, y)
C. Data type conversion function: Int (), float (), str ()
(2) Assigning a function name to a variable, you can call the function by the variable name.
(3) Defining functions
A. Define a function to use the DEF statement, write down the function name, parentheses, the arguments in parentheses, and the colon: and then, in the indent block, write the function body, and the return value of the function is returned with a return statement.
B.python's built-in functions have parameter checks, and custom functions need to add their own parameter checks, which are added in the Indent module first
If not isinstance (x, (int, float)):
Raise TypeError (' bad operand type ')
Parameters that represent functions are only integral and floating-point.
(4) NULL function
Application of Pass
(5) If you need to return a value, the function returns a tuple
Python notes 2