Python for a Coding Assessment
A refresher path through the Python graph for someone who has written Python before and has an assessment coming: run and read, rebuild the core, then work the way an assessment expects.
I can write a Python function with parameters, defaults and a return value, document what it does, and call it with positional and keyword arguments.
Writing a function someone else can call without reading its body, and calling one you did not write.
In scope: parameters and arguments, defaults, return values, docstrings, and the calling conventions Python offers. Out of scope: decorators, closures and type annotations, which have their own place later.
Everything a caller needs should be visible in the first line and the docstring: what goes in, what comes out, and what the function is for. A function whose behaviour depends on a global, or which returns different types depending on its input, has broken that promise even if it works.
Return something rather than printing, unless printing is the point. A function that prints can only be used one way; a function that returns can be printed, stored, tested or combined.
A function with no return returns None. That is a real value, and forgetting it is the source of
the classic bug where result is mysteriously None two lines later.
send(retry=3) reads at the call site.def f(items=[])) is shared by every call that omits it, which is the most
famous trap in the language. Use None and create the list inside.*args and **kwargs collect the rest. Useful for wrappers; a poor substitute for naming the
arguments you actually take.Take a working script with three near-identical blocks and have learners extract one function that serves all three. The argument list they end up with is the lesson: what genuinely varies, and what they were tempted to pass but did not need.
Then hand them the mutable-default trap as a puzzle before explaining it. Being surprised once fixes it permanently.
| Resource | Kind | Cost | Provider |
|---|---|---|---|
| The Python Tutorial: control flow and defining functions | reading | free | Python Software Foundation |
| Automate the Boring Stuff, chapter 3: functions | reading | free | Al Sweigart |
| CS50P, week 2: loops | video | free | Harvard University |
A refresher path through the Python graph for someone who has written Python before and has an assessment coming: run and read, rebuild the core, then work the way an assessment expects.
A timed take-home in the shape real hiring uses: read messy data, compute a result, test it, and hand over a repository someone else can run.
The holder can take an unfamiliar problem, write a tested Python solution someone else can run, and explain what it costs.
Nothing to show yet. The publisher last published on 2026-09-20, and no aggregate for this outcome has reached the 50 learners a number needs. Open Degree does not track learners. About learner evidence.