How to split a number into decimal and integer parts in Python

Splitting a number separates the decimal portion from the integer portion and returns each as floating-point numbers. For example, splitting 1.2426 into decimal and integer parts results in 0.24259999999999993 and 1.0, respectively.

Solution for How to split a number into decimal and integer parts in Python : You can use math.modf() to split a number into decimal and integer parts Call math.modf(num) to return a tuple containing the decimal and integers parts of num as floating-point numbers.


how-to-split-a-number-into-decimal-and-integer-parts-in-python