The math.log10()
function is used to calculate the base-10 logarithm of a number.
math.log10(x)
Where, x
is the number whose base-10 logarithm we want to calculate.
The function returns the logarithm of x to base 10.
import math
print(math.log10(10))
print(math.log10(50))
print(math.log10(100))
print(math.log10(200))
print(math.log10(1000))
The math.log10()
function is a shorthand for math.log() function with 10 as the base i.e math.log(x, 10)
import math
print(math.log10(100))
print(math.log(100, 10))
The function raises a ValueError
if the value of x
is negative.
import math
math.log10(-1)