What is a data type timedelta good for in Python?
Experience Level: Junior
Tags: Python
Answer
This data type represent the difference between two datetime objects.
Supported operators:
- add, subtract timedelta
- unary plus, minus, abs
- compare to timedelta
- multiply, divide by int
In addition, datetime supports subtraction of two datetime objects returning a timedelta, and addition or subtraction of a datetime and a timedelta giving a datetime.
Related Python job interview questions
How do you define an optional parameter with no value in Python?
Python JuniorHow do you define an optional parameter with a default value in Python?
Python JuniorWhat is the datetime data type good for in Python?
Python JuniorWhat is bool data type good for in Python?
Python JuniorWhat is a Set data type good for in Python?
Python Junior