Methode Python math.fmod()
Voorbeeld
Retourneer de rest van x/y:
# Import math Library
import math
# Return the remainder of x/y
print(math.fmod(20,
4))
print(math.fmod(20, 3))
print(math.fmod(15, 6))
print(math.fmod(-10, 3))
print(math.fmod(0, 0))
Definitie en gebruik
De math.fmod()
methode retourneert de rest (modulo) van x/y.
Syntaxis
math.fmod(x, y)
Parameterwaarden
Parameter | Description |
---|---|
x | Required. A positive or negative number to divide |
y | Required. A positive or negative number to divide x with |
Opmerking: Als zowel x als y = 0, wordt een ValueError geretourneerd.
Opmerking: als y = 0, wordt een ValueError geretourneerd.
Opmerking: als x of y geen getal is, wordt een TypeError geretourneerd.
Technische details
Winstwaarde: | Een float waarde, die de rest van x/y . voorstelt |
---|---|
Python-versie: | 1.4 |