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 148 views
1 answer 145 views
3 answers 179 views
2 answers 123 views
...