「數學」功能表

注意: 在建立使用此模組的新程式時,建議使用數學計算程式類型。如此將可確保所有相關模組皆已匯入。

項目

說明

from math import *

從數學模組匯入所有方法(函數)。

fabs()

傳回實數的絕對值。

sqrt()

傳回實數的平方根。

exp()

傳回 e**x。

pow(x,y)

傳回 x 的 y 乘冪。

log(x,base)

傳回 logbase(x)。

沒有底數的 log(x) 傳回自然對數 x。

fmod(x,y)

傳回 x 與 y 的模組值。當 x 和 y 為浮點值時使用。

ceil()

傳回大於或等於實數的最小整數。

floor()

傳回小於或等於實數的最大整數。

trunc()

將實數截斷為整數。

frexp()

傳回一對 (y,n),其中 x == y * 2**n。

 

Const

項目

說明

e

Returns value for the constant e.

pi

Returns value for the constant pi.

 

Trig

項目

說明

radians()

將角度單位從度數轉換為徑度。

degrees()

將角度單位從徑度轉換為度數。

sin()

傳回引數正弦的徑度。

cos()

傳回引數餘弦的徑度。

tan()

傳回引數正切的徑度。

asin()

傳回引數反正弦的徑度。

acos()

傳回引數反餘弦的徑度。

atan()

傳回引數反正切的徑度。

atan2(y,x)

傳回 y/x 反正切的徑度。