Explain Python try / except / finally with code, and specifically how finally behaves.
Asked in the technical interview stage. Implement finally_trace(mode) to return the order of events for several control-flow cases. The function must demonstrate that finally runs after normal execution, after a handled exception, before a returned value leaves the function, and before an unhandled exception propagates. Include a case showing that a return inside finally overrides an earlier return.
mode is one of success, handled, unhandled, return, or override. Return a list of event strings.
def finally_trace(mode):