Python functions
A function can be thought of as a function in mathematics, a piece of code that accomplishes a particular function.
-Absolute function abs ()
-Types function type ()
-Rounding function round ()
There are many built-in functions in Python, that is, functions that do not require additional import.
-CMP (), str (), and type () apply to all standard types. The following are numerical built-in functions and practical built-in functions.
The >>> dir (_builtins_) command can see built-in variables and built-in functions in Python.
The >>> Help (ABS) command is used to view assistance information for the ABS function.
The function floor () is a math library function, not an intrinsic function. Using a non-intrinsic function is the first thing to import its modules in.
# round-offFloor >>>import math>>>math.floor ( -35.4)-36.0> >>math.floor ( -35.5)-36.0>>>math.floor ( -35.8)-36.0
Python module
A complete Python file is a module.
-Documents: Physical organization math.py
-Module: Logical organization mode Math
Python often uses an "import module" to reuse functions, classes, and the like in off-the-shelf modules into other code blocks.
-After the math module is introduced, the value of the Math.PI can be used directly without the need to define it yourself.
The following is a statement that imports a single module, imports multiple modules, or imports the specified module properties (from Module name import module properties) inside the module.
Python Packages (Package)
The Python package defines a Python application execution environment that consists of modules and sub-packages. Manifest as a hierarchy of file directory structures. As follows: AAA is the top-level package, CCC, DDD ... is a sub-package, C1, C2 is the module in the sub-package. Can be imported and called by the right way. Importing: Importpackage name. Child Package name. Module
Python Library
A library is a collection of modules that have related functionality. One feature of Python is its powerful standard library, third-party libraries, and custom modules.
Relationships between packages, modules, libraries, functions, etc.
A package contains a module or a library, and there are many functions or classes within a module or library.
Using Python to play data: Python functions, modules, and packages