Metoda Python math.remainder().
Příklad
Vraťte zbytek x vzhledem k y:
# 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))
Definice a použití
Metoda math.remainder()
vrací zbytek x vzhledem k y.
Syntax
math.remainder(x, y)
Hodnoty parametrů
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. |
Technické údaje
Návratová hodnota: | Hodnota float představující zbytek |
---|---|
Verze Pythonu: | 3.7 |
Další příklady
Příklad
Vraťte zbytek 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))