Step 2: Write a python template

When sharing code with students I find it’s often useful to give them a starting point with 3-5 challenges written as comments that act as instructions for what to do.

I try to keep the templates as short and simple as possible so that students aren’t bombarded with loads of code. I also try to number the challenges so it’s easier to refer to them in class or for homework instructions. If possible, the challenges should be ordered from the easiest/shortest to the hardest / most time consuming so that all students can achieve the first one without feeling too overwhelmed or discouraged.

Example python template with numbered challenges in comments

Choosing what to include in your python template can take a lot of thought. Try to only include concepts and skills that students have already been introduced to. I usually design the templates around one of three types:

Try It: the python code you give students should run without any errors so that students can refer back to it as a reference. The challenges should be about tweaking how it works rather than writing anything completely new or fixing any bugs.

Debug It: the python code you give students should be deliberately sabotaged with some common mistakes so that students can develop confidence and resilience as they find and fix them. The challenges should explain what the code should do when each bug has been fixed.

Extend It: there might not be much python code in these activities as they act as more of a blank canvas with the challenges guiding students with some suggestions for what they could do to apply what they’ve learnt from previous activities.

Suggested styles of python templates

This is the methodology I’ve tried to use for the self-marking python activities on this site based on what seems to work for my students but you could use whatever structure or methodology that works best for you.

Tip:

You can save your code by pressing Ctrl + S which will create a new URL that anyone can use to access and run your code. If you’ve already saved it and want to update your code without changing the URL, you can press CTRL + SHIFT + S instead

Saving your code

The next page talks you through how to define the tests so that each of your challenges can be marked automatically.