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

1 Answer

0 votes
import math

num = 3.14159

result = math.modf(num)

decimal, integer = result

print(decimal) 

print(integer) 





'''
run:

0.14158999999999988
3.0

'''


 



answered Jul 14, 2022 by avibootz

Related questions

1 answer 160 views
1 answer 162 views
3 answers 197 views
2 answers 135 views
...