Module#6Assignment

Question 1:

import sys
from datetime import datetime
from datetime import time
from datetime import date


def main():

dt = datetime.now()
time_string = dt.strftime("%X")
# utc = datetime.utcnow()

for line in sys.stdin:
data = line.strip().split("\t")
if len(data) == 6:
_date, _time, store, item, cost, payment = data
print(f"{dt}\t{time_string}\t{store}\t{item}\t{cost}\t{payment}")

main()
The output from the code above took too long to produce and I don't know if it's because of the input 
volume in sys.stdin.
The code seems fine to run but it wasn't able to produce output when I tried to call the function main()

Question 2:
from datetime import timedelta

current_dt = datetime.now()
new_dt = current_dt + timedelta(days = 2*365) - timedelta(seconds = 60)
new_time_string = new_dt.strftime("%X")
print(new_dt)
Output:
2025-06-24 17:29:16.615776

Question 3:
# Creating a timedelta object that represent 100 days, 10 hours and 13 minutes
timedelta_object = timedelta(days = 100, hours = 10, minutes = 13)
print(timedelta_object)
Output:
100 days, 10:13:00

Question 4:
# Since I don't know how a function with feet and inches can be related to a timeobject,
# I just simply print out the parameters and the time object

def time_object(feet, inches):
print(f"feet: {feet}, inches: {inches}, timeobject: {timedelta_object}")

time_object(5, 10)
Output:
feet: 5, inches: 10, timeobject: 100 days, 10:13:00
I don't quite understand what should be the purpose of the function in question 4, if you can provide more
 details to the question through the grading comment section, that would be extremely helpful

Comments