
Returns the accurate floating-point sum of values in the iterable Returns a mantissa and exponent of x as the pair (m, e) Returns a remainder when x is divided by y Returns the largest integer less than or equal to x Returns the smallest integer value greater than or equal to x. See the below table, which has every Python Math module’s function with a description. Print('tan(x) is :', math.tan(angleInRadian)) Print('sin(x) is :', math.sin(angleInRadian)) Print('The given angle is :', angleInRadian) # app.pyĪngleInRadian = math.radians(angleInDegree) Print('log(fabs(x), base) is :', math.log(math.fabs(number), 10))Īll the trigonometric functions are available in python math module, so you can easily calculate them using sin(), cos(), tan(), acos(), asin(), atan() etc functions.Īlso, you can convert angles from degree to radian and radian to degree. Print('e^x (using exp() function) is :', math.exp(number)-1) Print('The given number (x) is :', number) Let’s see an example of the Python Math exp() and log() functions. The math.log() is a built-in Python method that returns the natural logarithm of a number, or the logarithm of a number to base. The “E” is the base of the natural system of logarithms (approximately 2.718282) and x is the number passed to it.

The math.exp() is a built-in Python library method that returns E raised to the power of x (E x). Print('Absolute value is :', math.fabs(number)) Print('Ceiling value is :', math.ceil(number)) Print('Floor value is :', math.floor(number)) The method ceil() returns the ceiling value of x – the smallest integer, which is not less than x. If the number is already an integer, then the same number is returned. The ceil() function returns the smallest integer value greater than the number. The pow() method returns the value of x to the power of y (x y). Python offers to compute the power of a number and hence can make calculating the power easier.

To calculate the power in Python, use the math.pow() function. The math.pow() is a built-in Python library function that returns the value of x to the power of y (x²). For that, you can use the cmath module as the complex counterpart. However, the math module does not support complex data types.

Mathematical functions like evaluating complex mathematical operations, such as trigonometric operations, logarithmic operations, etc., are under the math module. Python math is a built-in standard module used to work with complex scientific calculations. This function works in python 3.5 and above. gcd():- This function is used to compute the greatest common divisor of 2 numbers mentioned in its arguments.factorial():- It returns the factorial of x.floor():- It returns the largest integer less than or equal to x.ceil():- It returns the smallest integer value greater than or equal to x.fabs(): It returns the absolute value of x.In Python, some mathematical operations can be performed easily in the math module. After that, you can call any method of that module. To use the math in Python, import the module using import math statements in your program.
