Python3 acos() 函數(shù)

Python3 數(shù)字 Python3 數(shù)字


描述

acos() 返回x的反余弦弧度值。


語法

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

import math

math.acos(x)

注意:acos()是不能直接訪問的,需要導(dǎo)入 math 模塊,然后通過 math 靜態(tài)對(duì)象調(diào)用該方法。


參數(shù)

  • x -- -1到1之間的數(shù)值。如果x是大于1,會(huì)產(chǎn)生一個(gè)錯(cuò)誤。

返回值

返回x的反余弦弧度值。


實(shí)例

以下展示了使用 acos() 方法的實(shí)例:

#!/usr/bin/python3
import math

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

以上實(shí)例運(yùn)行后輸出結(jié)果為:

acos(0.64) :  0.8762980611683406
acos(0) :  1.5707963267948966
acos(-1) :  3.141592653589793
acos(1) :  0.0

Python3 數(shù)字 Python3 數(shù)字