The context is the high-level description of an exercise which provides details on what the learning objective of the exercise is, what the student is about to solve, and why. Any relevant background information goes in here. Contextualizing the exercises also contributes to the course narrative by tying in the dataset. You spent a lot of time during course design choosing the perfect dataset, talk about it! If you have fun datasets, make sure to play them up and get students interested and invested in your course. Furthermore, contextualizing your exercise helps students understand why the exercise is useful and provides a reference for them when they find themselves in a similar situation out in the wild.

When writing context, decide upon a single measurable learning objective for an exercise. Typically, the learning objective of an exercise is that the student understands some syntax, a workflow, a concept, or a result.


Typically this means learning how to use a function. For example:

  • The student can calculate model predictions using predict(), knowing that this function takes a model object and a data frame as arguments.
  • The student knows that Python classes are initialized with a method named __init__() and that this method takes self as the first argument.


This usually means knowing what order several functions should be called in. It can also refer to more abstract workflow ideas. For example:

  • The student can calculate groupwise summary statistics with dplyr, by first calling group_by()then calling summarize().
  • The student can articulate these modeling workflow steps: Split the data into training and testing sets, then train the model on the training set, then test the predictions on the testing set.


An abstract idea that can be either statistical, programming, or domain-specific. For example:

  • The student understands the definition of autocorrelation.
  • The student can predict what happens when an error occurs inside a try-block.
  • The student can calculate how depreciation affects the value of a thing over time.


An interesting finding from the dataset. For example:

  • The student can interpret that on average R programmers live eight years longer than SAS programmers.
  • The student can interpret that Python programmers are ten times more likely to own a pet snake than non-Python programmers.

Common problems and their solutions

  • Having too many learning objectives. In general, an exercise should teach the student precisely one thing. If you want to have multiple learning objectives, it's a warning sign that you are trying to cram too much into a single exercise. That said, if you have several simple learning objectives, a multi-step exercise can be appropriate.
  • The exercise doesn't test the learning objectives. It is important that the exercise meets the objective. One common danger is that you start writing code and somehow the exercise ends up being completely different from what you originally intended. This can be fine, but make sure that you are teaching the things that students will need to know for future exercises.
Did this answer your question?