How to play sounds (or run anything) on startup and shutdown with Raspbian

The Raspberry Pi is very handy for fun projects, and sometimes these projects require running specific events (like playing a sound) on startup or shutdown, or even in both instances – for an interactive machine that reacts to user input and presence, for example.

Sounds on startup and shutdown can also be used as a means of confirming those specific actions taking place – startup is complete and shutdown is taking place (and will complete in a very short while).