user8371532 user8371532 - 2 years ago 75
Python Question

Value of remainder

I am looking for a way to extract the remainder of a integer number in python. I am fairly new to Python and have dabbled in MatLab in college, nothing serious. I understand that the % operator reports the quantity of number placements in the remainder. I need to be able to get the actual value. As well as the actual value of the whole number but separate them to conduct the following equation:

Converting a time calculation from say 1.5minutes to 1.30 (1minute and .30seconds)

Eq. (((1.5-1)*60)/100)+1

Answer Source

In general, you extract the fractional part of a floating point number like this:

x = 1.5
x -= int(x)

However, as you mentioned minutes and seconds, I believe that what you really need is:

minutes = int(x)
seconds = (x-minutes)*60
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download