Python has built in a lot of useful functions that we can call directly. To invoke a function, you need to know the name and parameters of the function , such as an absolute function abs, which receives a parameter.
Documents can be viewed directly from the official website of Python: http://docs.python.org/2/library/functions.html#abs
You can also view the Help information for the ABS function on the interactive command line by helping (ABS).
Call the abs function:
When calling a function, if the number of arguments passed in is incorrect, the TypeError error is reported, and Python will explicitly tell you that ABS () has only 1 parameters, but gives two:
If the number of arguments passed in is correct, but the parameter type cannot be accepted by the function, the TypeError error is reported, and an error message is given: STR is the wrong parameter type:
The comparison function cmp (x, y) requires two parameters, if x<y, returns 1, if x==y, returns 0, if x>y, returns 1:
Python's built-in common functions also include data type conversion functions, such as the Int () function, which converts other data types to integers:
The STR () function converts other types to str:
The sum () function can accumulate:
There are, of course, more general-purpose functions that can be consulted when used in detail.