Python Math Module

Source: Internet
Author: User
Tags hypot natural logarithm pow square root

1.math Introduction

>>> Import Math

>>>dir (Math) #这句可查看所有函数名列表

[' __doc__ ', ' __name__ ', ' __package__ ', ' ACOs ', ' acosh ', ' asin ', ' Asinh ', ' atan ', ' atan2 ', ' Atanh ', ' ceil ', ' copysign ', ' Co  S ', ' 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 ', ' sq ' RT ', ' tan ', ' tanh ', ' trunc '

>>>help (Math) #查看具体定义及函数0原型

>>>help (math.function) # View functions under the Math Module

2. Common functions

Ceil (x) Fetch top

Return the ceiling of x as a float.

This is the smallest integral value >= x.

Floor (x) Bottom

Return the floor of X as a float.

This is the largest integral value <= x.

Fabs (x) Take absolute value

Return the absolute value of the float x.

Factorial (x) factorial

Find x!. Raise a valueerror if x is negative or non-integral.

Hypot (x, y) Right triangle bevel length

Return the Euclidean distance, sqrt (x*x + y*y)

The Y-square of the POW (x, y) x

Return x**y (x to the power of Y).

sqrt (x) Open Square

Return the square root of X.

Log (X[,base])

Return the logarithm of x to the given base.

If the base is not specified, returns the natural logarithm (base e) of X.

LOG10 (x)

Return the base ten logarithm of X.

Trunc (x) truncation of rounding parts

Truncates x to the nearest Integral toward 0. Uses the __trunc__ Magic method.

isNaN (x) determines whether Nan (not a number)

Check if float x is not a number (NaN)

Degrees (x) radian Turn angle

Convert angle x from radians to degrees.

radians (x) angle to radians

Convert angle x from degrees to radians.

In addition, the module defines two constants:

E = 2.718281828459045

PI = 3.141592653589793

Python Math Module

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.