Método Python math.fmod()
Exemplo
Retorne o resto de 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))
Definição e uso
O math.fmod()
método retorna o restante (módulo) de x/y.
Sintaxe
math.fmod(x, y)
Valores de parâmetro
Parameter | Description |
---|---|
x | Required. A positive or negative number to divide |
y | Required. A positive or negative number to divide x with |
Nota: Se x e y = 0, ele retornará um ValueError.
Nota: Se y = 0, retorna um ValueError.
Nota: Se x ou y não for um número, ele retornará um TypeError.
Detalhes técnicos
Valor de retorno: | Um float valor, representando o restante de x/y |
---|---|
Versão do Python: | 1,4 |