average time calculation??

Ian Kelly ian.g.kelly at gmail.com
Thu Jan 10 17:48:39 EST 2013


On Thu, Jan 10, 2013 at 1:31 PM, pmec <pcurad01 at gmail.com> wrote:
> Hi Oscar, again I do apologize for my beginner mistakes, I've changed the code taking in consideration some of your and MRAB suggestions.
>
> Could you give me an example on how could I use the datetime.timedelta function in this particular case.

td1 = timedelta(minutes=mins1, seconds=secs1, milliseconds=hundredths1*10)
td2 = timedelta(minutes=mins2, seconds=secs2, milliseconds=hundredths2*10)
average = (td1 + td2) / 2
mins, secs = divmod(average.seconds, 60)
hundredths = average.microseconds // 10000
print("{:02d}:{:02d}:{:02d}".format(mins, secs, hundredths))



More information about the Python-list mailing list