What is math.log10() in Python?

The log10() function uses the base 10 to calculate the logarithm of a number.

Figure 1 shows the mathematical representation of the log10() function and the corresponding representation in Python.

Figure 1: Mathematical representation of the log10() function and the corresponding representation in Python

The math module is required for this function.

Syntax

log10(number)

Parameter

This function requires a number whose logarithm base 10 is to be calculated, and it must be greater than zero.

Return value

log10() uses the base 10 to return the logarithm of a number.

Example

The following example shows how we can use the log10() function in Python.

#Module required
import math
#example
print ("log10(10) : ", math.log10(10))
print ("log10(2) : ", math.log10(2))
print ("log10(15.2) : ", math.log10(15.2))