I often mentor students on their very first day of coding. The most frequent question beginners ask is “What is the difference between print and return?”
It is a surprisingly difficult question to answer. For a start, you can’t use any jargon, which is an incredibly hard habit to break. In my mind,
return are defined in terms of other programming concepts such as functions. To make matters worse, students often start coding in an interpreter, which gives the strong impression that
return are identical.
I have asked many developers to answer this question without using any technical words. Can you explain the difference between
return without using any of these words?
And of course, the words “print” and “return” are not allowed. The answer “print prints and return returns” is most definitely not allowed.
In the first workshop, I usually explain variables before
return. In a previous post, I explained a variable as analogous to a cardboard box.
return is like asking your friend to grab an item from the box, and give it back to you.
When we’re mentoring beginners, it’s important to try and link concepts to what the student already knows about.
Talking to machines is a weird new concept, and words like “function” or “STDOUT” don’t yet mean anything. However, the student probably knows what a box is.
As much as you can, try to link abstract programming ideas to everyday decisions and objects.