python——常用的数学计算公式

文章目录??e的指数????ln????平方????开根号????角度转弧度??e的指数

??exp()?? 方法返回x的指数,e的x次方。

math.exp(x)

示例:

print “math.exp(119L) : “, math.exp(119L)print “math.exp(math.pi) : “, math.exp(math.pi)# 运行结果math.exp(119L) : 4.7978133273e+51math.exp(math.pi) : 23.1406926328ln

math.log(x) 就相当于数学中的ln(x),x>0,求底数为e的对数; math.log10(x) 就相当于数学中的lg(x),x>0,求底数为10的对数。

math.log(x)

示例:

print “math.log(math.pi) : “, math.log(math.pi)# 设置底数print “math.log(10,2) : “, math.log(10,2)# 运行结果math.log(math.pi) : 1.14472988585math.log(10,2) : 3.32192809489平方math.pow(x,2) 求4的平方

示例:

print “math.pow(4,2) : “, math.pow(4,2)# 运行结果math.pow(4,2) : 16开根号math.sqrt(x)

示例:

print “math.sqrt(100) : “, math.sqrt(100)print “math.sqrt(7) : “, math.sqrt(7)print “math.sqrt(math.pi) : “, math.sqrt(math.pi)# 运行结果:math.sqrt(100) : 10.0math.sqrt(7) : 2.64575131106math.sqrt(math.pi) : 1.77245385091角度转弧度

??radians()?? 方法将角度转换为弧度。

角度和弧度关系是:2π 弧度 = 360°。从而 1°≈0.0174533 弧度,1 弧度≈57.29578°。

角度转换为弧度公式:弧度=角度÷180×π弧度转换为角度公式: 角度=弧度×180÷πmath.radians(x)

示例:

print (“radians(90) : “, math.radians(90)) # 1 弧度等于大概 57.3°print (“radians(45) : “, math.radians(45))print (“radians(30) : “, math.radians(30))print (“radians(180) : “, math.radians(180)) # 180 度的弧度为 πprint(“180 / pi : “, end =””)print (math.radians(180 / math.pi))# 运行结果radians(90) : 1.5707963267948966radians(45) : 0.7853981633974483radians(30) : 0.5235987755982988radians(180) : 3.141592653589793180 / pi : 1.0

快乐不是因为得到的多而是因为计较的少!

python——常用的数学计算公式

相关文章:

你感兴趣的文章:

标签云: