Modf Function - Python Math Module

Method Name: 

modf(aNumber_in)

Method Overview: 

- modf() function of math module in python returns the integer and the fractional parts as a tuple. 

- The modf() function returns both the integer and the fractional parts 
with the same sign as the parameter.

- Both integer and the fractional parts are of type floating point number

 

Example:

import math

 

# Get the integer and fractional values for Rayleigh factor

RayleighFactor   =  1.2196698912

RayleighTuple    = math.modf(RayleighFactor)

print("Printing RayleighFactor as a tuple in python... integer first and fraction next")

print(RayleighTuple)

 

# Truncate Constant of Theodorus

ConstantofTheodorus = 1.7320508075

TheodorusTuple      = math.modf(ConstantofTheodorus)

print("Printing Theodorus Constant as tuple in python...integer first and fraction next")

print(TheodorusTuple)

Output:

Printing RayleighFactor as a tuple in python... integer first and fraction next

(0.2196698911999999, 1.0)

Printing Theodorus Constant as tuple in python...integer first and fraction next

(0.7320508075000001, 1.0)


Copyright 2022 © pythontic.com