Question:
Can I include code in the exercise context?
Answer:
We highly recommend including code in the exercise context, especially in intro courses.
You have two good choices here. Either you can include a general code pattern that the students have to make more specific in the exercise, or you can use a concrete example that is different from the one that the students have to write in the exercise.
For example, suppose the objective of the exercise is for students to be able to select the id
and date
columns from a Pandas DataFrame named customers
.
# Select id and date columns from customers
customers[['id', 'date']]
The code pattern approach would be to include something like the following.
# Select multiple columns from a DataFrame
dataset[['column1', 'column2']]
The concrete example would be include something like this.
# Select product_name and quantity from orders
orders[['product_name', 'quantity']]
Related