Steps in Sequential exercises build on one another and are usually used when solving a problem requires several operations, each of which is complex enough to deserve its own instructions and a check on whether it has been done correctly. For example, if you want the learner to print a data frame to view NaNs, then drop rows with NaNs and view the output again, this is the perfect type of exercise. Another interesting feature of Sequential exercises is that you can mix exercise types - specifically, Sequential exercises can consist of both Coding and Multiple Choice with Console exercises. This allows you to have a learner run some code and then test their ability to interpret the output.
Guidelines
Sequential exercises should have:
Maximum context of length 780 characters (recommended is 540).
Between 2 - 4 steps (recommended is 3).
Each step should have instructions of length 10 - 240 characters (recommended is 120).
A total of 4 instructions, regardless of the number of steps, e.g., a two-step exercise can have no more than four instructions, and a four-step exercise can have no more than four instructions.
If a Sequential exercise includes a Multiple Choice with Console step, it does not contribute to the maximum number of Multiple Choice exercises per course.
Code in each step should build off of the code from previous steps. Solution code from previous steps should remain in the sample code for subsequent steps, including code comments, spacing, and order. Previous code should not be modified between steps (other than print statements). For example, given the following code:
Step 1 sample code:
# Create a list of arrival times
arrival_times = [____(____, ____, ____)]
print(arrival_times)
Step 1 solution code:
# Create a list of arrival times
arrival_times = [range(10, 60, 10)]
print(arrival_times)
In the step 2 sample code, lines 1-2 are exactly the same as lines 1-2 in the step 1 solution code. Note that the print statement has been removed since learners no longer need to view arrival_times
, but all other code is exactly the same.
# Create a list of arrival times
arrival_times = [range(10, 60, 10)]
# Convert arrival_times to an array and update the times
arrival_times_np = np.____(____)
new_times = ____ - ____
print(new_times)
Step 2 solution code:
# Create a list of arrival times
arrival_times = [range(10, 60, 10)]
# Convert arrival_times to an array and update the times
arrival_times_np = np.array(arrival_times)
new_times = arrival_times_np - 3
print(new_times)
In the step 3 sample code, lines 1-6 are exactly the same as lines 1-6 of the solution code from the previous step. Again, the print statement has been removed since learners no longer need to view new_times
, but all other code is exactly the same.
# Create a list of arrival times
arrival_times = [range(10, 60, 10)]
# Convert arrival_times to an array and update the times
arrival_times_np = np.array(arrival_times)
new_times = arrival_times_np - 3
# Use list comprehension and enumerate to pair guests to new times
guest_arrivals = [(names[____],____) for ____,____ in ____(new_times)]
print(guest_arrivals)