Python math.fmod() Metode
Voorbeeld
Gee die res van x/y terug:
# 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))
Definisie en gebruik
Die math.fmod()
metode gee die res (modulo) van x/y terug.
Sintaksis
math.fmod(x, y)
Parameterwaardes
Parameter | Description |
---|---|
x | Required. A positive or negative number to divide |
y | Required. A positive or negative number to divide x with |
Let wel: As beide x en y = 0, gee dit 'n ValueError.
Let wel: As y = 0, gee dit 'n ValueError terug.
Let wel: As x of y nie 'n getal is nie, gee dit 'n TypeError.
Tegniese besonderhede
Terugkeerwaarde: | 'n float Waarde wat die res van x/y voorstel |
---|---|
Python weergawe: | 1.4 |