Python math.log10() Method
Python math.log10(x)The method returns the base-10 logarithm of x.
Syntax
The syntax of the math.log10() method is as follows:
math.log10(x)
Parameter Description:
- x-- Required. A number. If x is not a number, a TypeError is returned. If the value is 0 or negative, a ValueError is returned.
Return Value
Returns a float, representing the base-10 logarithm of a number.
Example
The following example returns the base-10 logarithm of a number:
Example
# Import the math package
import math
# Output the base-10 logarithm of a number
print(math.log10(2.7183))
print(math.log10(2))
print(math.log10(1))
import math
# Output the base-10 logarithm of a number
print(math.log10(2.7183))
print(math.log10(2))
print(math.log10(1))
Output Result:
0.43429738512450866 0.3010299956639812 0.0Other Extensions
Python math Module