Page 315 - CTS - CSA TP - Volume 2
P. 315
COMPUTER SOFTWARE APPLICATION - CITS
• This line creates a new datetime object representing a date and time one day later than the current time.
• This line creates a new datetime object representing a date and time two hours earlier than the current time
• Finally, the code prints out the formatted current time, the time one day later, and the time two hours earlier.
In summary, the code demonstrates working with dates and times, formatting them as strings, and performing
basic arithmetic operations on them using the datetime and timedelta classes.
Output:
Related Exercises:
1 Write a program that calculates the area of a circle given its radius using the math module.
2 Write a program that displays the current date and time using the datetime module.
3 Write a program that displays the calendar using the calendar module.
300
CITS : IT & ITES - Computer Software Application - Exercise 136