Latest web development tutorials

Python asin() 函數

Python 數字 Python數字


描述

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


語法

以下是asin() 方法的語法:

import math

math.asin(x)

注意: asin()是不能直接訪問的,需要導入math模塊,然後通過math靜態對象調用該方法。


參數

  • x -- -1到1之間的數值。 如果x是大於1,會產生一個錯誤。

返回值

返回x的反正弦弧度值。


實例

以下展示了使用asin() 方法的實例:

#!/usr/bin/python
import math

print "asin(0.64) : ",  math.asin(0.64)
print "asin(0) : ",  math.asin(0)
print "asin(-1) : ",  math.asin(-1)
print "asin(1) : ",  math.asin(1)

以上實例運行後輸出結果為:

asin(0.64) :  0.694498265627
asin(0) :  0.0
asin(-1) :  -1.57079632679
asin(1) :  1.57079632679

Python 數字 Python數字