Teaching students how to check code: Give someone a fish and you feed them for a day; teach someone to fish and you feed them for a lifetime

I am teaching second-year physics students computational physics; I have been doing this for 20 years. One of things that has frustrated me for a few years is students asking me to check results, when they just want to know if the answer is right or wrong. When I help students who ask this question I do try and take students through my reasoning. For example, if the correct result of the calculation is a Gaussian function, I briefly describe what a Gaussian looks like.

But ultimately, I am at least part of the problem here. It is my fault. By marking students on whether they get the right answer or not, I am part of the problem. We have an education system which encourages students to view marks as more important that acquiring skills and knowledge, and so if I come along and reward students who get the right answer with marks, the right answer is what they are going to want to get.

And of course it is good to get the right answer. But to paraphrase the well-known proverb in the title of this post: give a student the correct answer, and they know one right answer; teach them how to code well, and they have (mostly) correct answers for a lifetime. The thing the students will hopefully find useful in their future careers, is not an answer to a problem I am using in a computer lab, but the ability to write code themselves that gives the correct answer.

So, I changed one of the Jupyter notebooks to be explicit both on the need to check codes, and on possible ways of doing the checks. It is on Colab here if you want to take a look. As is the way when I change something, I am unable to predict the consequences. The immediate consequence was me being kept very busy by students who had done what exactly what I had asked them: calculate a number via two different methods and check to see that the methods agree. They then found that the two methods gave different values, and asked me for help on working out why.

I think I had fondly imagined the students would, if they found a discrepancy, find the source of the error themselves and then think good thoughts about my wisdom*, which says a lot about the level of my optimism/lack of grasp of reality. But having students check for an error and take action when this showed a problem is definitely progress.

So although there are things I need to work for next year when I teach it again, at least the course now makes an important point about learning how to code, and students are learning from it.

* To be fair, some may have done that, but of course I wouldn’t know.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s