Método Python math.remainder()
Python mathremainder(x, y)El método devuelve el resto de x/y.
Versión de Python: 3.7
Sintaxis
La sintaxis del método math.remainder() es la siguiente:
math.remainder(x, y)
Descripción de parámetros:
- x-- Obligatorio, dividendo.
- y-- Opcional, divisor. Debe ser un número distinto de cero; de lo contrario, se producirá un ValueError.
Valor de retorno
Un valor flotante que devuelve el resto.
Ejemplo
El siguiente ejemplo calcula el resto:
Ejemplo
# Importar el módulo math
import math
# resto de x/y
print (math.remainder(9, 2))
print (math.remainder(9, 3))
print (math.remainder(18, 4))
print (math.remainder(23.5, 5))
print (math.remainder(23, 5.5))
print (math.remainder(12.5, 2.5))
print (math.remainder(12, 2))
import math
# resto de x/y
print (math.remainder(9, 2))
print (math.remainder(9, 3))
print (math.remainder(18, 4))
print (math.remainder(23.5, 5))
print (math.remainder(23, 5.5))
print (math.remainder(12.5, 2.5))
print (math.remainder(12, 2))
Salida:
1.0 0.0 2.0 -1.5 1.0 0.0 0.0Otras extensiones
Módulo Python math