02Python common modules _ 01 math, 02python_01math

Source: Internet
Author: User

02Python common modules _ 01 math, 02python_01math
1. Integer:

>>> Import math >>> math. ceil (2.3) # rounded up 3 >>> math. floor (2.7) # rounded down 2 >>> round (2.3) # rounded down 2
>>> Round (2.12345, 3)
2.123
2. trigonometric function:
Math. cos (x) math. sin (x) math. tan (x) # The return value is the number of radians math. acos (x) math. asin (x) math. atan (x) math. degrees (x) # radians to angle math. radians (x) # degrees to radians
3. logarithm & Index:
Math. exp (3) # e ^ xmath. pow (x, y) # x ^ y ''' In particle, pow (1.0, x) and pow (x, 0.0) always return 1.0, even when x is a zero or a NaN. '''math. sqrt (x) # The 2nd power math of x. log (2, 4) # log4 (2) math. log10 (3) # equivalent to math. log (3, 10)
4. Constant:
Math. pi # π math. e # emath. inf # + ∞, equivalent to float ('inf ')

 

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.