-
It is important to check if students are returning specific things correctly. If they are just assuming that Python will return the right thing, this may signify a deep misunderstanding about what Python can do.
-
Help students develop a better mental model of the protocol for when a function gets called (for how the function runs from beginning to end).
-
Use tools like Python Tutor (http://pythontutor.com/visualize.html#) and Java Visualizer (http://cscircles.cemc.uwaterloo.ca/java_visualize/) to help students build their mental model of function calls.
-
This allows students to trace through the steps from the beginning of a function call through to return.
-
-
-
Make sure to distinguish the differences between print statements and return statements to help students understand that these elements are not related.
-
Print statements contribute to this misconception because the functionality of a print statement overlaps with their mental model of what return is supposed to do.
-
Until print statements come into the equation and induce confusion, teachers might think students understand print statements.
-
One strategy to avoid this confusion is to delay introducing print statements until after students have a solid understanding of return.
-