Python入门之三角函数sin()函数实例详解

Oriel ·
更新时间:2024-09-21
· 954 次阅读

描述

sin()返回的x弧度的正弦值。

语法

以下是sin()方法的语法:

importmath math.sin(x)

注意:sin()是不能直接访问的,需要导入math模块,然后通过math静态对象调用该方法。

参数

x--一个数值。

返回值

返回的x弧度的正弦值,数值在-1到1之间。

实例

以下展示了使用sin()方法的实例:

#!/usr/bin/python import 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)

以上实例运行后输出结果为:

sin(3) : 0.14112000806 sin(-3) : -0.14112000806 sin(0) : 0.0 sin(math.pi) : 1.22460635382e-16 sin(math.pi/2) : 1

总结

以上就是本文关于Python入门之三角函数sin()函数实例详解的全部内容,希望对大家有所帮助。感兴趣的朋友可以继续参阅本站:python正则表达式re之compile函数解析、Python中enumerate函数代码解析、简单了解Python中的几种函数等,有什么问题可以随时留言,小编会及时回复大家的。感谢朋友们对本站的支持!

您可能感兴趣的文章:Python入门之三角函数全解【收藏】Python入门之三角函数tan()函数实例详解Python入门之三角函数atan2()函数详解Python中计算三角函数之cos()方法的使用简介用Python计算三角函数之atan()方法的使用Python计算三角函数之asin()方法的使用用Python计算三角函数之acos()方法的使用Python绘制三角函数图(sin\cos\tan)并标注特定范围的例子



Python入门 sin Python

需要 登录 后方可回复, 如果你还没有账号请 注册新账号