Using Python to play data: Python functions, modules, and packages

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.