Hi guys , I’m a noob .
I made a program who asks for a time and when i write 1.5 minutes it understands 90 seconds .
what do I have to do to make it understand that 1.5 minutes = 1min and 30 seconds ?
Thanks a lot
Hi guys , I’m a noob .
I made a program who asks for a time and when i write 1.5 minutes it understands 90 seconds .
what do I have to do to make it understand that 1.5 minutes = 1min and 30 seconds ?
Thanks a lot
I don’t understand what you’re asking. There are 60 seconds in a minute, so 60 * 1.5 = 90 seconds.
1.5 minutes isn’t 60+50 seconds.
1 minute is 60 seconds. Half a minute (0.5) is 30 seconds. Add them together and you get 1.5 minutes = 90 seconds.
divmod
is a function you could use to convert seconds into minutes and seconds.
Multiplying by 60 is good.
And divmod is useful too.
I’ve been using a module I wrote long ago for this. It’s at modunits.py
There’s also cfunits · PyPI which I haven’t used, but might be pretty nice.