Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python log10() function

Python log10() function

Python Numbers Python Numbers


Description

The log10() method returns the base-10 logarithm of x.


Syntax

The syntax of the log10() method is as follows:



import math



math.log10( x )

**Note:** log10() cannot be accessed directly; you need to import the math module and call the method through the static object.


Parameters


Return Value

Returns the base-10 logarithm of x, where x>0.


Example

The following shows examples of using the log10() method:



#!/usr/bin/python

import math   # 导入 math 模块



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)

Running the example above produces:



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 Python Numbers