Méthode Python math.reste()
Exemple
Renvoie le reste de x par rapport à 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))
Définition et utilisation
La math.remainder()
méthode renvoie le reste de x par rapport à y.
Syntaxe
math.remainder(x, y)
Valeurs des paramètres
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. |
Détails techniques
Valeur de retour : | Une float valeur, représentant le reste |
---|---|
Version Python : | 3.7 |
Plus d'exemples
Exemple
Renvoie le reste de 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))