Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract the decimal value of float in python

I have a program that is a converter for times in minutes and seconds and returns a float value with a decimal, for example:

6.57312

I would like to extract the .57312 part in order to convert it to seconds.

How can I get python to take only the value after the decimal point and put it into a variable that I can then use for the conversion?

like image 589
Evan Gilbert Long Avatar asked Nov 28 '22 23:11

Evan Gilbert Long


1 Answers

You can do just a simple operation

dec = 6.57312 % 1
like image 181
rafaelc Avatar answered Dec 05 '22 02:12

rafaelc