欢迎光临
我们一直在努力

如何在python中使用三角函数

python中使用三角函数的方法

1.正弦函数

python中的正弦函数是sin()函数,其作用是返回的x弧度的正弦值。

sin()函数语法:

math.sin(x)

sin()函数使用方法:

import math #导入math模块

print "sin(3) : ", math.sin(3)

print "sin(-3) : ", math.sin(-3)

print "sin(0) : ", math.sin(0)

print "sin(math.pi) : ", math.sin(math.pi)

print "sin(math.pi/2) : ", math.sin(math.pi/2)

2.余弦函数

python中的cos()函数,其作用是返回x的弧度的余弦值。

cos()函数语法:

math.cos(x)

cos()函数使用方法:

import math #导入math模块

print "cos(3) : ", math.cos(3)

print "cos(-3) : ", math.cos(-3)

print "cos(0) : ", math.cos(0)

print "cos(math.pi) : ", math.cos(math.pi)

print "cos(2*math.pi) : ", math.cos(2*math.pi)

3.正切函数

python中的正切函数是tan()函数,其作用是返回x弧度的正切值。

tan()函数语法:

math.tan(x)

tan()函数使用方法:

import math #导入math模块

print "tan(3) : ", math.tan(3)

print "tan(-3) : ", math.tan(-3)

print "tan(0) : ", math.tan(0)

print "tan(math.pi) : ", math.tan(math.pi)

print "tan(math.pi/2) : ", math.tan(math.pi/2)

print "tan(math.pi/4) : ", math.tan(math.pi/4)

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。