带有Python示例的math.log10()方法
Pythonmath.log10()方法
math.log10()方法是math模块的库方法,用于获取数字的以2为底的对数,它接受数字并返回给定数字的以10为底的对数。
该方法math.log10()给出了更准确的结果比所述日志(X,10)。
注意:如果我们提供除数字以外的任何其他内容,该方法将返回TypeError–“TypeError:需要浮点数”。
math.log10()方法的语法:
math.log10(x)
Parameter(s):x–是要计算其以10为底的对数的数字。
返回值:float-它返回一个浮点数,该浮点数是数字x的以10为底的对数。
示例
Input:
x = 21
#函数调用
print(math.log10(x))
Output:
1.3222192947339193Python代码演示math.log10()方法的示例
#python代码演示示例
#math.log10()方法
#导入数学模块
import math
#以10为底的对数
x = 21
print("Base-10 logarithm of ", x, " is = ", math.log10(x))
x = 10.23
print("Base-10 logarithm of ", x, " is = ", math.log10(x))输出结果
Base-10 logarithm of 21 is = 1.3222192947339193 Base-10 logarithm of 10.23 is = 1.0098756337121602
热门推荐
10 车行销售祝福语简短
11 离职横幅升职祝福语简短
12 赞美老师祝福语英文简短
13 考生大学后祝福语简短
14 给哥嫂结婚祝福语简短
15 狼狈伴郎祝福语毕业简短
16 中秋送健康祝福语简短
17 喜得新房文案祝福语简短
18 同事有趣祝福语大全简短