Copyright © tutorialspoint.com
This function returns the fractional and integer parts of x in a two-item tuple. Both parts have the same sign as x. The integer part is returned as a float.
import math math.modf( x ) |
Note: This function is not accessible directly so we need to import math module and then we need to call this function using math static object.
Here is the detail of parameters:
x: This is a numeric expression.
See the description
#!/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) |
This will produce following result:
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) |
Copyright © tutorialspoint.com