Brain DeCoded with CodeX - Mission 4, Objective 2: Pattern Recognition

Mission 4 · Objective 2 Lesson Plan

Pattern Recognition

Students learn which parts of the brain find patterns, then write the algorithm that lets a CodeX do the same job on a word the user types in.

⏱ 45-70 min 🎯 Grades 8-12+ 💻 CodeSpace 🎮 CodeX 🧠 Algorithms
View Lesson Outline
📋

Overview

Objective 1 made the case that language runs on patterns. This objective shows students who is doing the pattern finding, first in the brain and then in code.

Students read how the visual cortex, temporal lobe, parietal lobe, hippocampus, and prefrontal cortex split the work of recognizing, remembering, and categorizing patterns. Then they build repeated_letters, a program that asks for a word on the Console and displays it on the CodeX with consecutive repeated letters in yellow and everything else in blue.

That is an algorithm, a fixed set of steps, not a neural network. Worth naming the difference out loud, because students often assume any computer that finds a pattern must be "learning." Algorithms are just the right place to start.

🎯 Project Goal: Students add code to a program that detects repeated letters.

🎯

Learning Targets

  • I can identify parts of the brain used in pattern recognition.
  • I can explain what an algorithm is.
💡

Key Concepts

  • Many parts of the brain work together to recognize, remember, and make sense of patterns in everything from faces to languages.
  • Computers can recognize patterns using algorithms.
  • Using an algorithm and neural network processing are different, but learning about algorithms is a good place to start.
✅

Assessment Opportunities

  • Turn in the Activity Guide.
  • Complete the program repeated_letters.
☑

Success Criteria

  • Complete the CodeTrek steps
  • Program runs correctly without errors
  • Activity Guide is completed
📂

Digital Resources

🧰

Classroom Materials

  • ▸CodeX device and USB cable, one per student
  • ▸Laptop/computer with Chrome browser
🚀

Extensions & Cross-Curricular

ExtensionFor students with programming experience, have them review the code for find_repeating_letters() and print_word() and explain each line. How are the two functions alike? How are they different?
MathMathematics uses algorithms too. Kaprekar's Constant is a good one to try. Students follow the algorithm with different starting numbers and see where it lands.
🔤

Vocabulary

▾
Algorithm:a step-by-step process for solving a problem or performing a calculation.
Visual Cortex:the part of the brain that processes visual information.
🐍

New Python Code

▾
for i in range(len(word))Looping structure that traverses a list (word)
for i in repeated_lettersLooping structure that traverses a list (repeated_letters)
word = input("enter a word")Type string input to the Console and assign it to a variable
if word[i] == word[i+1]:If statement that compares the current item in the list with the next item in the list
display.print(word[i], end='')Prints the current item in the list and stays on the same line, so the next item does not start a new line
📐

Standards

▾

Computer Science

9-12.AP.14

English Language Arts & Literacy

RST.9-10.4 RST.11-12.4
📝
Preparing for the Lesson
  • Run the program yourself first, Console and all. Knowing what a finished run looks like on the CodeX makes it much faster to spot where a student's version went wrong.
  • Know where the Console is before class. It is the icon below the Toolbox, and students will not find it on their own.
  • Decide how students get the Activity Guide. You can print a copy for each student or assign it digitally.
  • Have a few test words ready that show different results: one with a double letter, one with none, and one with two doubles.
  • Look over the brain diagram in the reading. Students do better on the learning target if you can point to each region as it comes up.

🧑‍🏫
Teacher Notes
  • The program uses the Console for input. Students need to click the Console icon below the Toolbox. When the program runs, a prompt appears. Type the word to search and press Enter.
  • Students should follow the instructions on the Activity Guide and record their results.
  • The program only finds consecutive repeated letters. "letter" has one pair, "banana" has none. That surprises students, and it is a good conversation about what the algorithm was actually told to do.
  • This objective is where the algorithm and neural network distinction gets made. Students tend to call anything that finds a pattern "AI," so it is worth correcting early.
  • Extensions and cross-curricular projects are included to enhance the concepts in the objective. You can use the extensions to extend students' learning.
🗺️

Lesson Outline

🗣️Warm-up / Hook

Start with how fast the brain does this.

  • Ask: "You spot a friend across a crowded room in about a tenth of a second. How did your brain do that so fast?"
  • Ask: "If you had to write down the exact steps for recognizing a face, what would step one be?"
Teaching tip: The second question is the whole lesson in miniature. Students find out quickly that something their brain does instantly is very hard to write as a list of steps, which is exactly what an algorithm has to be.
🧠Reading & Discussion

Students work through the reading on brain regions and machine pattern recognition.

  1. Students read the section on the visual cortex and how the brain stores features as patterns.
  2. Walk the brain diagram: visual cortex, temporal lobe and the fusiform gyrus, parietal lobe, hippocampus, prefrontal cortex. Give each one a one-line job.
  3. Move to Machine Power: detecting shapes in images, finding a face in a photo, reading handwriting.
  4. Define algorithm as a class before anyone opens the code.
Teaching tip: Five brain regions is a lot at once. Assign one region per pair, have each pair explain theirs in a sentence, and the whole list gets covered in about five minutes.
💻Student Work Time

Students build repeated_letters.

  1. Students work through the CodeTrek steps, adding code to repeated_letters.
  2. In find_repeating_letters(), students build the empty list, compare each letter with the next one, and append the positions of any match.
  3. In print_word(), students loop through the word and print each letter in yellow if its position is in the list, blue if it is not.
  4. Students open the Console, run the program, and type a word at the prompt.
  5. Students test several words and record the results on the Activity Guide.
Teaching tip: Nothing appears to happen until the Console is open. If a student says the program is frozen, that is the first thing to check, every time.
✏️Wrap-up & Review

Close on the difference between an algorithm and a brain.

  • Ask: "Your program found the repeated letters. Did it understand the word?"
  • Ask: "Which part of what your brain does was your algorithm actually doing, and which parts did it skip?"
  • Collect the Activity Guides.
Teaching tip: Keep the answers to that first question. The rest of the mission pushes on it, and students who already said "no, it just compared letters" are set up well for what comes next.