1.math Module
>>> 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 ']
Math.e
Math.PI
Math.copysign (X,y): Returns the X value of the same number as Y.
Math.ceil (x); Returns the smallest integer of <=x
Math.floor (x): Returns the largest integer of >=x
Math.hypot (x,y): Back to sqrt (x*x + y*y)
MATH.MODF (x); Returns the fractional part of X and the whole number of parts
Math.trunc (x); Returns the integer portion of x
Math.pow (x,y): Back to X**y
Math.log (X,a): Returns the logarithm that returns the base x of a, if parameter A is not specified, the default is E
MATH.LOG10 (x)
2.random Module
Random.random (): Generates a 0<=x,1 random floating-point number
Random.uniform (); Generates a random floating-point number within a specified range
Random.randint (A,B): Generates an integer between a<=x<=b
Random.randrange (a,b,step): Generate a random number
Random.choice (Sequence): Gets a random element from the sequence, a list tuple string
Random.shuffle (list): Scrambling lists
Random.sample (sequence,k): Randomly get fragments of a specified length of k from a sequence.
3.decimal Module
GetContext (). Prec, set the precision of the decimal point.
>>> from decimal import decimal,getcontext
>>> print (Decimal (' 1.0 ')/decimal (' 3.0 '))
0.3333333333333333333333333333
>>> getcontext (). Prec = 6
>>> print (Decimal (' 1.0 ')/ Decimal (' 3.0 '))
0.333333
4.fractions Module
Used to perform and process fractions
>>> from fractions import fraction
>>> print fraction (1,3)
1/3