Método Python math.remainder()
Exemplo
Retorne o resto de x em relação 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))
Definição e uso
O math.remainder()
método retorna o restante de x em relação a y.
Sintaxe
math.remainder(x, y)
Valores de parâmetro
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. |
Detalhes técnicos
Valor de retorno: | Um float valor, representando o restante |
---|---|
Versão do Python: | 3.7 |
Mais exemplos
Exemplo
Retorne o resto 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))