Teaching Python

We're two middle school teachers learning and teaching Python

Five Strategies to promote Pattern Awareness in Python

"Art is the imposing of a pattern on experience, and our aesthetic enjoyment is recognition of the pattern.”

― Alfred North Whitehead



Pattern recognition is a fundamental skill that holds great importance in Computer Science education. In 2016, a study by Rittle-Johnson et al. investigated the impact of teaching pattern recognition in early mathematics education. The findings revealed that cultivating students' ability to identify patterns and fostering strong pattern awareness had a positive influence on their comprehension of more complex math concepts in subsequent years. Basic pattern awareness suggests that the brain actively engages with concepts and endeavors to establish connections between previously identified patterns. This, in turn, boosts students' confidence in dealing with advanced math topics.

Engaging with patterns and making connections not only aids comprehension but also enhances the retention of concepts. Pattern awareness is a staircase-level skill with complexity that increases as the difficulty of the concepts increases. When students become good at identifying simple patterns, they began seeing these patterns and applying them to concepts elsewhere. Therefore, drawing deeper connections with the subject area.

The Cognitive Theory of Pattern Recognition Techniques states that patterns are dependent on a person's knowledge or experience. When dealing with patterns, increasing experiences and information can help the brain seek out templates or other prototypes in long-term memory. (This topic has helped stem machine learning topics regarding pattern recognition in computers. To read more about pattern recognition, click here: https://www.analyticsvidhya.com/blog/2020/12/patterns-recognition-the-basis-of-human-and-machine-learning/ )

Applying this technique to concepts taught in Computer Science is a great way to help students identify patterns in the specific coding language and transfer the knowledge to other Object Oriented languages. "Over time, exposure to these problem-solving situations gives us a subconscious familiarity with their essential nature that we can hardly articulate in words, but which we can easily put into action. (NOVA, 2013)"

An effective way to introduce pattern recognition in Computer Science is by using the concept of objects and methods. Even in the first few days of teaching students to code, showing how methods are applied to an object can help students progress as they learn more complex Python concepts. Helping students see the pattern between an object and the methods applied to an object helps them build the baseline understanding of how the relationships between them work in an object-oriented programming language without introducing OOP.


Below are five tips on how you can begin teaching patterns using Objects and methods.

1) Repeat and Highlighting

One of the first things to do after printing "Hello World" is to teach the students variable names and 'how to' assign a string data type. However, do not just type a variable and write a string. Try to have a specific way of repeating and highlighting the existing pattern and making a routine for future code-along activities. In our coding class, we refer to each data type as an object and reference the variable name interchangeably when referring to data types. (This simplifies things for Newbies.)

2) Active Teaching

We focus a lot of our attention and time in the early weeks, reading each python line of code aloud as if we were saying it in a sentence. We read both from right to left and left to right, ensuring that each symbol is correctly identified, seen, and spoken. This active teaching strategy helps to commit the language recognition to long-term memory.

For example:

This line of code will read:
[right to left] -- "the string Kelly is assigned to the object/variable, 'first underscore name' or
[left to right] -- "the object with the variable name, 'first underscore name' is assigned to the string Kelly.

I often interchange the words variable and object to reinforce that these are variable names, and we use them as placeholders. I try not to commit to the word variable or the object at this point but stick to saying both. However, identifying these as objects makes it easier to talk about applying a method to an object. (Remember these are 10/11-year-olds coding for the first time.)

3) Tangible metaphors

It is essential to associate the pattern with something familiar or tangible to a new coder. For example, if we use a metaphor for an object they know, like a piece of bread, when we start to discuss methods, it is easy to explain that a method can be applied to an object. We can use bread as our object, and 'Toast' is our method. We can apply the "toasting" method to the bread to change it. We can also apply the "buttering" method to a piece of bread to change it to 'buttered bread.'

Did you notice how the object has a method applied to it? This reminder helps students make connections when we transition from strings to lists or dictionaries.

4) Identify syntax patterns

The other pattern to highlight when working with objects and methods is the syntax and specifically the parentheses. Calling attention to the parentheses at the end of the method will prepare the learner to consider later what can happen inside the parentheses of the methods.

For example, when we append a list or apply the method append to a list object, we can fill in the parenthesis with the object we want to append. Identifying the parentheses early on in a string method like .lower() calls attention that this is a pattern in Python.

5) Always reinforcing the Basic Pattern

Calling attention to other instances that require understanding objects and methods, is when we work with libraries such as the turtle library or the pillow library.

For example, often expert coders 'import turtle as t' or 'from turtle import *.' However, I prefer not to teach these at first and show students only 'import turtle.' (You can also use the 'from turtle import Turtle' option, and it helps to accomplish the same pattern without needing to explain turtle.Turtle())

This import helps enforce the rule that students need to use the object turtle with a new name; thus, when we apply methods to the turtle, we can make it 'move.'

Keeping to the basic patterns reinforces that a 'method is applied to an object,' and the object is 'turtle.' Using the import and naming turtle as t may lead students away from seeing patterns. Furthermore, can also identify new names of turtles as Bob or Sally for more turtle fun. This helps to call attention to the pattern that existed when working with strings and lists and other data types. We also can reinforce the argments within the parenthesis.

These are just a few of the ways to teach pattern recognition in early Python coders. The simple things you do when teaching the basics of Python can make a huge difference in students understanding later on. Helping students see the patterns with the grammar and syntax of any language can help students see the bigger picture. This solid knowledge base provides a template for coders when moving to more complex topics such as objects and functions.


Resources

Rittle-Johnson, Bethany & Zippert, Erica & Boice, Katherine. (2018). The roles of patterning and spatial skills in early mathematics development. Early Childhood Research Quarterly. 46. 10.1016/j.ecresq.2018.03.006.

"The Science of Smart: The Virtues of Confusion." PBS, Public Broadcasting Service, 19 Feb. 2013, www.pbs.org/wgbh/nova/article/the-science-of-smart-the-virtues-of-confusion/.

Youguo Pi, Wenzhi Liao, Mingyou Liu, and Jianping Lu (2008). Theory of Cognitive Pattern Recognition, Pattern Recognition Techniques, Technology and Applications, Peng-Yeng Yin (Ed.), ISBN: 978-953-7619-24- 4, InTech, Available from: http://www.intechopen.com/books/pattern_recognition_techniques_technology_and_applications/theory_of_co gnitive_pattern_recognition



Shop with Teaching Python