The math.log10() method is used to calculate the base-10 logarithm of a given number.
Syntax
import math
math.log10(num)
Parameter
num(required): The number for which you want to calculate the base-10 logarithm. num must be a positive number.
Return Value
Returns the base-10 logarithm of a number as a float value
It throws a ValueError if the num is 0 or negative number.
It throws a TypeError if the num is not a number.
Visual Representation
Example 1: How to Use math.log10() Method
# Importing math library
import math
print(math.log10(5))
print(math.log10(10))
print(math.log10(2.7))
Output
0.6989700043360189
1.0
0.43136376415898736
Example 2: Passing 0 and negative value
import math
print(math.log10(-5))
print(math.log10(0))
Output
ValueError: math domain error
ValueError: math domain error