Python3 sin() 函数

Python 3 教程 · 2019-02-05 18:11:43

描述

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

语法

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

import math

math.sin(x)

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

参数

  • x -- 一个数值。

返回值

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

实例

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

#!/usr/bin/python3
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.1411200080598672
sin(-3) :  -0.1411200080598672
sin(0) :  0.0
sin(math.pi) :  1.2246467991473532e-16
sin(math.pi/2) :  1.0

点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html

查看所有标签

Foundation Web Standards

Foundation Web Standards

Jonathan Lane、Steve Smith / Friends of ED / 21st July 2008 / $34.99

Foundation Web Standards explores the process of constructing a web site from start to finish. There is more to the process than just knowing HTML! Designers and developers must follow a proper proces......一起来看看 《Foundation Web Standards》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具