Date Arithmetic with Timedelta in Python
📖 Scenario: Imagine you work in a library. You have a list of books with their borrow dates. You want to find out when each book should be returned by adding a fixed borrowing period.
🎯 Goal: You will create a dictionary of books with their borrow dates, set a borrowing period, calculate the return dates by adding the borrowing period to each borrow date, and finally display the return dates.
📋 What You'll Learn
Create a dictionary with book titles as keys and borrow dates as datetime objects as values
Create a variable for the borrowing period using timedelta
Calculate return dates by adding the borrowing period to each borrow date using a dictionary comprehension
Print the dictionary of return dates
💡 Why This Matters
🌍 Real World
Libraries, rental services, and any system that tracks borrowed items use date arithmetic to calculate due dates.
💼 Career
Understanding date arithmetic is important for data analysts and scientists working with time series data, scheduling, and event tracking.
Progress0 / 4 steps