Python Number log10() Method


Advertisements


Description

The method log10() returns base-10 logarithm of x for x > 0.

Syntax

Following is the syntax for log10() method −

import math

math.log10( x )

Note − This function is not accessible directly, so we need to import math module and then we need to call this function using math static object.

Parameters

  • x − This is a numeric expression.

Return Value

This method returns base-10 logarithm of x for x > 0.

Example

The following example shows the usage of log10() method.

Live Demo
#!/usr/bin/python
import math   # This will import math module

print "math.log10(100.12) : ", math.log10(100.12)
print "math.log10(100.72) : ", math.log10(100.72)
print "math.log10(119L) : ", math.log10(119L)
print "math.log10(math.pi) : ", math.log10(math.pi)

When we run above program, it produces following result −

math.log10(100.12) :  2.00052084094
math.log10(100.72) :  2.0031157171
math.log10(119L) :  2.07554696139
math.log10(math.pi) :  0.497149872694

python_numbers.htm

Advertisements