"""Greeting construction: pure functions with no I/O, easy to test.""" import datetime DEFAULT_NAME = "friend" def time_of_day_greeting(now=None): """Return a salutation that matches the local time of day.""" hour = (now or datetime.datetime.now()).hour if 5 <= hour < 12: return "Good morning" if 12 <= hour < 18: return "Good afternoon" return "Good evening" def greet(name=DEFAULT_NAME, shout=False, salutation=None): """Build a greeting such as "Hello, Ada!".""" if salutation is None: salutation = "Hello" message = f"{salutation}, {name}!" return message.upper() if shout else message