math.log2(x)x 的以 2 為基數的對數。math.log2(x)
x (float): 要計算對數的數值。x 的以 2 為基數的對數。import math
print(math.log2(16)) # 輸出: 4.0
math.log10(x)x 的以 10 為基數的對數。math.log10(x)
x (float): 要計算對數的數值。x 的以 10 為基數的對數。import math
print(math.log10(100)) # 輸出: 2.0
math.pow(x, y)x 的 y 次方。math.pow(x, y)
x (float): 底數。y (float): 指數。x 的 y 次方。import math
print(math.pow(2, 3)) # 輸出: 8.0
math.sqrt(x)x 的平方根。math.sqrt(x)
x (float): 要計算平方根的數值。x 的平方根。import math
print(math.sqrt(9)) # 輸出: 3.0
math.acos(x)x 的反餘弦值,結果範圍在 0 到 π 之間。math.acos(x)
x (float): 要計算反餘弦值的數值,範圍為 -1 到 1。x 的反餘弦值(弧度)。import math
print(math.acos(1)) # 輸出: 0.0
math.asin(x)x 的反正弦值,結果範圍在 -π/2 到 π/2 之間。math.asin(x)
x (float): 要計算反正弦值的數值,範圍為 -1 到 1。x 的反正弦值(弧度)。import math
print(math.asin(1)) # 輸出: 1.5707963267948966