Latest web development tutorials

modf función de Python ()

cifras Python cifras Python


descripción

modf () devuelve la parte entera y la parte fraccionaria de x, signo del valor de las dos partes con las mismas x, la parte entera de la representación de coma flotante.


gramática

El siguiente es el método modf sintaxis ():

import math

math.modf( x )

Nota: modf () no es directamente accesible, debe importar el módulo de matemáticas, invoque el método a través del objeto estático.


parámetros

  • x - expresión numérica.

Valor de retorno

Devuelve la parte entera y la parte fraccionaria de x,

Ejemplos

A continuación se muestra un ejemplo del uso método modf ():

#!/usr/bin/python
import math   # This will import math module

print "math.modf(100.12) : ", math.modf(100.12)
print "math.modf(100.72) : ", math.modf(100.72)
print "math.modf(119L) : ", math.modf(119L)
print "math.modf(math.pi) : ", math.modf(math.pi)

Después de ejecutar la salida anterior ejemplo es:

math.modf(100.12) :  (0.12000000000000455, 100.0)
math.modf(100.72) :  (0.71999999999999886, 100.0)
math.modf(119L) :    (0.0, 119.0)
math.modf(math.pi) :  (0.14159265358979312, 3.0)

cifras Python cifras Python