Python math.remainder()メソッド
例
yに関するxの余りを返します。
# Import math Library
import math
# Return the remainder of x/y
print (math.remainder(9, 2))
print (math.remainder(9,
3))
print
(math.remainder(18, 4))
定義と使用法
このmath.remainder()
メソッドは、yに関してxの余りを返します。
構文
math.remainder(x, y)
パラメータ値
Parameter | Description |
---|---|
x | Required. The number you want to divide. |
y | Required. The number you want to divide with. It must be a non-zero number, or a ValueError occurs. |
技術的な詳細
戻り値: | float 余りを表す値 |
---|---|
Pythonバージョン: | 3.7 |
その他の例
例
x / yの余りを返します。
print (math.remainder(23.5, 5))
print
(math.remainder(23, 5.5))
print (math.remainder(12.5, 2.5))
print
(math.remainder(12, 2))