Python Math.remainder() Metoda
Przykład
Zwróć resztę z x w odniesieniu do 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))
Definicja i użycie
Metoda math.remainder()
zwraca resztę x względem y.
Składnia
math.remainder(x, y)
Wartości parametrów
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. |
Szczegóły techniczne
Wartość zwrotu: | Wartość float reprezentująca resztę |
---|---|
Wersja Pythona: | 3,7 |
Więcej przykładów
Przykład
Zwróć resztę 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))