描述
這個sin()方法返回 x 的正弦值,以弧度為單位。
用法
以下是語法sin()方法 -
sin(x)
注意− 此函數不可直接訪問,因此需要導入 math 模塊,然後使用 math 靜態對象調用此函數。
參數
x- 這必須是一個數值。
返回值
此方法返回一個介於 -1 和 1 之間的數值,表示參數 x 的正弦值。
示例
下麵的例子展示了 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.14112000806 sin(-3): -0.14112000806 sin(0): 0.0 sin(math.pi): 1.22460635382e-16 sin(math.pi/2): 1
相關用法
- Python 3 Number shuffle()用法及代碼示例
- Python 3 Number sqrt()用法及代碼示例
- Python 3 Number seed()用法及代碼示例
- Python 3 Number tan()用法及代碼示例
- Python 3 Number atan()用法及代碼示例
- Python 3 Number ceil()用法及代碼示例
- Python 3 Number cos()用法及代碼示例
- Python 3 Number max()用法及代碼示例
- Python 3 Number round()用法及代碼示例
- Python 3 Number acos()用法及代碼示例
- Python 3 Number fabs()用法及代碼示例
- Python 3 Number log()用法及代碼示例
- Python 3 Number randrange()用法及代碼示例
- Python 3 Number hypot()用法及代碼示例
- Python 3 Number exp()用法及代碼示例
- Python 3 Number degrees()用法及代碼示例
- Python 3 Number log10()用法及代碼示例
- Python 3 Number radians()用法及代碼示例
- Python 3 Number choice()用法及代碼示例
注:本文由純淨天空篩選整理自 Python 3 - Number sin() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。