math - python module
math python module provides mathematical function.
math module is always available.
math module provides access to the mathematical functions defined by the C standard.
The functions in math module can not be used with complex numbers.
In these case, the functions in cmath module can be used with complex numbers.
The returned variables data type of functions in math module are generally floats.
math.ceil(x)
return the ceiling of x as a float.
The celling of x is the smallest integer value greater than or equal to x.
math.copysign(x,y)
return x with the sign of y.
On a platform that supports signed zeros, copysign(1.0, -0.0) returns -1.0.
math.fabs(x)
return the absolute value of x
math.factorial(x)
return x factorial.
ValueError will be raised if x is not integer or is negative.
math.floor(x)
return the floor of x as a float, the largest integer value less than or equal to x.
math.fmod(x,y)
math.fmod(x,y) return x-n*y for some integer such that the result has the same sign as x, and x-n*y is less than abs(y).
Python's x%y returns x-n*y for some integer such that the result has the same sign as y, and x-n*y is less than abs(y).
For example,
fmod(-1e-100,1e100) = -1e-100.
-1e-100 % 1e100 = 1e100-1e-100.
fmod() is preferred when working with floats.
% is preferred when working with integers.
math.frexp(x)
Return the mantissa and exponent of x as the pair (m, e).
m is a float and e is an integer such that x == m * 2**e exactly.
If x is zero, returns (0.0, 0), otherwise 0.5 <=abs(m) < 1.
...
[0]