transform exercise to implement function instead top level code

as the function as introduced earlier, we transform exercises
to implement functions earlier in course
ignore argument_unpacking.rst as it is a link