In the scitools courses e.g. https://github.com/SciTools/courses/blob/master/course_content/iris_course/1.The_Iris_Cube.ipynb
the approach is to put each example in it's own file, and then include a way to load it inside the relevant worksheet using:
SAMPLE SOLUTION:
Un-comment and execute the following, to view a possible solution, and some code.
Then run it ...
# SAMPLE SOLUTION
# %load solutions/iris_exercise_1.2a
this has two advantages:
- it makes it easier for the user to access the relevant answers
- it make it easier to test (no need to cut and paste the solutions in)