Exercise 2 solution from datetime import datetime, timezone, timedelta def compare(a, b): try: if a < b: return "before" if a > b: return "after" return "same instant" except TypeError: return "cannot compare" n1 = datetime(2026, 3, 5, 9, 0) n2 = datetime(2026, 3, 5, 10, 0) u1 = datetime(2026, 3, 5, 9, 0, tzinfo=timezone.utc) e1 = datetime(2026, 3, 5, 4, 0, tzinfo=timezone(timedelta(hours=-5))) e2 = datetime(2026, 3, 5, 9, 0, tzinfo=timezone(timedelta(hours=-5))) print(compare(n1, n2)) print(compare(u1, e1)) print(compare(u1, e2)) print(compare(e2, u1)) print(compare(n1, u1)) print(n1 == u1) Output (run, and exactly as shown): before same instant before after cannot compare False Explanation: two naive values compare by their clock readings. Two aware values compare by the instant they name, so 04:00 at -5 hours equals 09:00 UTC, while 09:00 at -5 hours is five hours later than 09:00 UTC. Ordering a naive value against an aware one raises TypeError, which the function turns into a message. Note that == does not raise: it quietly returns False, so an equality test cannot tell you that the two kinds were mixed.