Python Math Module
Python math module is defined as the most famous mathematical functions, which includes trigonometric functions, representation functions, logarithmic functions, etc. Furthermore, it also defines two mathematical constants, i.e., Pie and Euler number, etc.
Pie (n): It is a well-known mathematical constant and defined as the ratio of circumstance to the diameter of a circle. Its value is 3.141592653589793.
Euler's number(e): It is defined as the base of the natural logarithmic, and its value is 2.718281828459045.
There are different math modules which are given below:
This method returns the natural logarithm of a given number. It is calculated to the base e.
log(fabs(x), base) is : -6.698970004336019
This method returns base 10 logarithm of the given number and called the standard logarithm.
log10(x) is : 1.1139433523068367
This method returns a floating-point number after raising e to the given number.
The given number (x) is : 0.05 e^x (using exp() function) is : 0.05127109637602412
This method returns the power of the x corresponding to the value of y. If value of x is negative or y is not integer value than it raises a ValueError.
The power of number: 100.0
This method returns the floor value of the x. It returns the less than or equal value to x.
The floor value is: 10
This method returns the ceil value of the x. It returns the greater than or equal value to x.
The floor value is: 11
This method returns the absolute value of x.
The absolute value is: 10.001
This method returns the factorial of the given number x. If x is not integral, it raises a ValueError.
The factorial of number: 5040
This method returns the fractional and integer parts of x. It carries the sign of x is float.
The modf of number: (0.5, 44.0)
Python provides the several math modules which can perform the complex task in single-line of code. In this tutorial, we have discussed a few important math modules.
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week