《Python Math 函数.docx》由会员分享,可在线阅读,更多相关《Python Math 函数.docx(2页珍藏版)》请在三一办公上搜索。
1、Python Math 函数Python Math 函數 必須 import math 功能說明 傳回 x 的反餘弦 傳回 x 的反雙曲餘弦 傳回 x 的反正弦 傳回 x 的反雙曲正弦 傳回 x 的反正切 傳回 y/x 的反正切 傳回 x 的反雙曲正切 傳回 x 的最小整數 傳回與 y 同號的 x 值 傳回 x 的餘弦 傳回 x 的雙曲餘弦 指令 math.acos(x) math.acosh(x) math.asin(x) math.asinh(x) math.atan(x) math.atan2(y,x) math.atanh(x) math.ceil(x) math.copysign(x
2、,y) math.cos(x) math.cosh(x) 範例 math.floor(3.4) 結果 4 math.floor(3.4) 結果 3 將 x (徑) 轉成角度,與 radians 為反函數 math.degrees(x) 常數 e = 2.7128. 傳回 ex也就是 math.e*x 傳回 x 的絕對值 傳回 x! 傳回 x 的最大整數 傳回 y % x,以 float 而言 fmod 優於 % 傳回一個 2 元組 (2-tuple) 分別是假數 m (float)以及 一個指數 n(int),也就是 x = m2n與 ldexp 是反函數 傳回 x 陣列值的各項和 傳回 ma
3、th.fsum(x) math.hypot(x,y) math.frexp(x) math.e math.exp(x) math.fabs(x) math.factorial(x) math.floor(x) math.fmod(x,y) math.frexp(1.625) (0.8125,1) 結果 math.frexp(2,5) 結果 7 如果 x = inf 也就是 傳回 True 如果 x = Non (not a number) 傳回 True 傳回 m2n與 frexp 是反函數 math.isinf(x) math.isnan(x) math.ldexp(m,n) math.lo
4、g(x,a) 傳回 ,若不寫a 內定 e 傳回 math.log10(x) 傳回 math.loglp(x) math.modf(x) math.pi math.pow(x,y) 傳回傳回 x 的小數部份與整數部份 傳回常數 (3.14159.) 傳回 xy 將 x(角度) 轉成徑,與 degrees 為反函數 math.radians(d) 傳回 x 的正弦 傳回 x 的雙曲正弦 math.sin(x) math.sinh(x) math.sqrt(x) math.tan(x) math.tanh(x) math.trunc(x) 傳回 傳回 x 的正切 傳回 x 的雙曲正切 傳回 x 的整數部份,等同 int