Python math.fmod()メソッド
例
x / yの余りを返します。
# Import math Library
import math
# Return the remainder of x/y
print(math.fmod(20,
4))
print(math.fmod(20, 3))
print(math.fmod(15, 6))
print(math.fmod(-10, 3))
print(math.fmod(0, 0))
定義と使用法
このmath.fmod()
メソッドは、x / yの余り(モジュロ)を返します。
構文
math.fmod(x, y)
パラメータ値
Parameter | Description |
---|---|
x | Required. A positive or negative number to divide |
y | Required. A positive or negative number to divide x with |
注: xとyの両方が0の場合、ValueErrorが返されます。
注: y = 0の場合、ValueErrorを返します。
注: xまたはyが数値でない場合は、TypeErrorが返されます。
技術的な詳細
戻り値: | float x / yの余りを表す値 |
---|---|
Pythonバージョン: | 1.4 |