Python math.remain() Metodo
Esempio
Restituisce il resto di x rispetto a 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))
Definizione e utilizzo
Il math.remainder()
metodo restituisce il resto di x rispetto a y.
Sintassi
math.remainder(x, y)
Valori dei parametri
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. |
Dettagli tecnici
Valore di ritorno: | Un float valore, che rappresenta il resto |
---|---|
Versione Python: | 3.7 |
Altri esempi
Esempio
Restituisce il resto di 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))