Data Processing and Standard Libraries
This assignment provided an opportunity to deepen my understanding of Python’s datetime, timedelta, and relativedelta classes, as well as creating practical functions and processing iterative data. The task required modernizing and extending several code snippets provided by the instructor, translating them into Python 3 syntax and enhancing them to perform multiple time-based operations.
Learning Outcomes
Through the completion of this assignment, I gained practical experience in:
- Working with time-based classes such as datetime.now(), timedelta(), and relativedelta().
- Performing arithmetic operations on datetime objects, including adding days and years and subtracting seconds.
- Understanding how timedelta stores its internal state in terms of days, seconds, and microseconds.
- Writing custom functions that take parameters and utilize time objects for output formatting.
- Simulating tab-separated input without relying on sys.stdin, which proved problematic in an IDE environment.
Challenges Encountered
A key challenge occurred while attempting to work with sys.stdin, as this resulted in a looping state during testing within the IDE. To address this, I replaced the stdin input with a simulated list of tab-separated strings. This allowed for testing the logic of the loop without system input blocking the execution. Additionally, it was necessary to install the dateutil package to use relativedelta, which is not included in Python’s standard library.
Final Outcome
The final version of the script includes all required components structured into clearly labeled steps. It meets the requirements of the assignment while maintaining readability, modularity, and logical flow. Each step is self-contained and clearly annotated for ease of understanding.
The code has been uploaded to my GitHub repository and can be accessed at the following link:
π GitHub Repository β Module 6 Assignment
Here are the snapshots of the results. However, please feel free to download the code from GitHub and test it yourself.
