Showing Structural Similarity in Introductory Programming

Aakash Gautam
Feb 20 · 4 min read

I am a teaching assistant in a class called “Introduction to Computational Thinking” where we use BlockPy, a web-based Python programming environment that allows students to work with blocks as well as text (both separately and together). The focus of the course is on helping non-CS students to think about abstractions, algorithms, and social impacts contextualized through problem statements involving a wide range of “real world” dataset.

As part of a classwork assignment, students were working on iterations on a list of measures related to weather in Blacksburg (where the university is located). In half of these assignments, students needed to iterate through the list, make a decision, compute a measure (e.g. sum or count), and outside of the list print the measure. In one assignment students needed to count the number of days where the temperature had gone above or equal 80 (hot days).

Few of the students were struggling in solving the problem. Three of the students had solutions that looked like this:

In the example, the student had initialized a variable (max_temp) and was checking whether that max_temp was greater than or equal to 80. The code executes (because of the initialized variable) and gives an output 0 no matter how many hot days there have been (and there have been plenty!).

From the student’s perspective, they were doing everything correctly. They were checking if the temperature was greater than or equal to 80, they were iterating and counting, and they were printing the right variable.

The need to iterate first and then compare each of the temperatures is not easy to grasp especially when presented with abstract elements like programming blocks. In previous semesters, I used to sit with the students and talk to them about the code. I would usually ask them to write pseudo-code in English on a piece of paper and compare with the blocks they have created on BlockPy. The surface-level similarity between the pseudo code and the blocks helped in clarifying the confusion. While it had worked earlier, I knew I could make it more approachable.

With the overarching goal to charm the students about computing, I chose to show that computational constructs are analogical to several day-to-day activities. I hypothesized that if I could show that there are elements of structural similarity in the approach using the blocks and the way we do things in everyday life, it may help in clarifying the programming confusion as well as help in long-term retention.

I started with an example that was a nearly-everyday problem for me: finding a matching (or similar-looking) pair of socks from a large collection. It has structural similarity with the programming problem: they both require taking an item out of a container and evaluating the item after taking it out. I asked the students how they would find a matching pair. With the first student, I drew as they explained (as seen alongside). Later, I asked the students to draw as they explained. I then put the drawing in front of their screen and asked them to compare the steps. While one immediately understood the issue and made changes to the blocks, others needed further explanation. In this case too, I tried to push students to breakdown the problem and see how those steps were structurally similar to part of the blocks. They grasped the issue and could tell me what changes needed to be made.

However, it is common for students to “fall in love with their code” i.e. be hesitant to make changes, especially when it requires large changes and when they think they are “very close” to the answer. Both the students had similar resistance so I tried to draw upon the structural analogy that they had just encountered. I took their blocks and separated them apart (as seen in the image alongside). This helped both the students and they were able to make the changes.

There are several wonderful, inspiring work in Computer Science education (and Computational Thinking) that teach introductory programming in various ways. For example, Media Computation attempts to do so through creative expression and several approaches blend computational concepts with science and mathematics. I am certain all of them would require instructors to sit with students and provide personalized care and support. At those times — and other times too — showing the structural similarity between the student’s everyday experiences and the programming problem may help. And talking about socks can never hurt!

P.S. Please note that the correct answer required the students to remove the block “set max_temp = 0” from the top. This was a separate issue and hence not discussed here.

Age of Awareness

Stories providing creative, innovative, and sustainable changes to the education system

Aakash Gautam

Written by

Learner.

Age of Awareness

Stories providing creative, innovative, and sustainable changes to the education system