Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,939 questions

51,876 answers

573 users

How make calculation with timedelta in Python

2 Answers

0 votes
import datetime
 
td = datetime.timedelta(days=1)     
print('1 day:', td)     
print('7 days:', td * 7)     
print('3.5 days:', td * 3.5)     
print('1/3 day:', td / 3)




'''
run:

1 day: 1 day, 0:00:00
7 days: 7 days, 0:00:00
3.5 days: 3 days, 12:00:00
1/3 day: 8:00:00

'''

 



answered Jun 6, 2019 by avibootz
0 votes
import datetime
 
work_time = datetime.timedelta(hours=9)     
project_time = datetime.timedelta(hours=2.5)     

print(work_time / project_time)



'''
run:

3.6

'''

 



answered Jun 6, 2019 by avibootz

Related questions

...