温馨提示×

python中对数函数如何表示

养鱼的猫咪
494
2021-03-05 08:01:12
栏目: 编程语言

python中对数函数如何表示

在python中使用log()方法表示对数函数,具体方法如下:

log()语法:

math.log(x[, base])

参数:

x:数值表达式。

base:表示底数,默认为e。

log()使用方法:

import math # 导入math模块

print "math.log(100.12) : ", math.log(100.12)

print "math.log(100.72) : ", math.log(100.72)

print "math.log(119L) : ", math.log(119L)

print "math.log(math.pi) : ", math.log(math.pi)# 设置底数

print "math.log(10,2) : ", math.log(10,2)

输出结果为:

math.log(100.12) : 4.60636946656

math.log(100.72) : 4.61234438974

math.log(119L) : 4.77912349311

math.log(math.pi) : 1.14472988585

math.log(10,2) : 3.32192809489

0