Python Learning Note 2-modules

Source: Internet
Author: User

Use of modules

Two types of reference modules

Form one: Import module_name

Form two: From Module1 import Module11 (Module11 is a submodule of module)

Example: referencing the exact Division module

Import

The math module in Python needs to be used for operations such as Root, exponentiation, and logarithmic.

>>>Importmath>>> dir (Math)#View the features provided by this module [‘__doc__‘,‘__file__‘,‘__name__‘,‘__package__‘,‘ACOs‘,‘Acosh‘,‘Asin‘,‘Asinh‘,‘Atan‘,‘Atan2‘,‘Atanh‘,‘Ceil‘,‘Copysign‘,‘Cos‘,‘Cosh‘,‘Degrees‘,‘E‘,‘Erf‘,‘Erfc‘,‘Exp‘,‘Expm1‘,‘Fabs‘,‘Factorial‘,‘Floor‘,‘Fmod‘,‘Frexp‘,‘Fsum‘,‘Gamma‘,‘Hypot‘,‘Isinf‘,‘isNaN‘,‘Ldexp‘,‘Lgamma‘,‘Log‘,‘Log10‘,‘log1p‘,‘Modf‘,‘Pi‘,‘Pow‘,‘Radians‘,‘Sin‘, ' sinh " '  ' trunc ' ]>>> Help (Math.pow)  See how to use the function Help on built- iny (X to the power of Y). END)            

Enter Q to exit interactive mode in interactive mode

>>> Math.pow (4,2)       # represents 4 of the powers of 16.0>>> Math.pow (3,2) 9.0
>>> 4**2
16

Python Learning Note 2-modules

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.