Level 4

Secret Codes

Level 4 · Chapter 13

What this lesson follows

CSTA K–12 Computer Science Standards (2017)

Data & Analysis · Grades 6–8

Store the same data in different codes.

Code 2-DA-07Read the official text

Common Core State Standards for Mathematics

Number & Operations in Base Ten · Grade 5

Work with big numbers and decimals.

Code 5.NBT.B.6Read the official text

The short lines are our own words. We matched this lesson to these standards ourselves; the standards' owners have not reviewed or endorsed this course.

Common Core State Standards © 2010 National Governors Association Center for Best Practices and Council of Chief State School Officers. All rights reserved.

Today you will pull a bonus letter out of a code word, then show that code three ways: the letter, its number, and its color.

1👋 Warm-Up

For teachers · goals · guide
Lesson Outcomes · for teachersCSTA 2
✦ CSTA 2-DA-07 · ISTE 1.5.c · Standards
🎯 I canpull a bonus letter out of a code word, then show that code three ways: the letter, its number, and its color
🧩 New blocks1 block
📝 New words5 words
⏱ Lesson time~45 min
Teacher Guide

📋 Before class

⚠️ Common misconceptions

  • Students think the bonus code has only one form. The letter h IS the number 8 IS a color — one code, three forms.
  • Students swap the two list blocks. item # of takes a letter and gives its position number; item ( ) of takes a position number and gives the letter. They are opposites.
  • Students use = for the bonus check. = needs an exact match, so extra typed letters break it. contains looks inside the typed letters.
  • Students mix up letter ( ) of and length of. letter (1) of [hat] gives one letter, h. length of [hat] gives a count, 3.

🎯 Differentiation

🐢 Struggling: Give a paper alphabet strip numbered 1 to 26. Write the code word hat in three boxes numbered 1, 2, 3. Let students point to letter 1 and read its number before touching Scratch.

🚀 Advanced: Give each apple its own code letter. Add the code number of every caught apple to a list, then decode the list back into a word.

💡 During the lesson

  • Warm-UpWrite "hat → h = 8 = 🟦" on the board next to a screenshot of the Chapter 12 Catch Game. Ask students to name other codes they know (traffic lights, jersey numbers, emoji). The big idea: one piece of game data, many forms. This is CSTA 2-DA-07 — represent data using multiple encoding schemes. The chapter adds four small scripts to the game students already own; nothing is rebuilt from zero. Students last used letter ( ) of and length of in Level 3 Chapter 12 — this chapter puts those two string blocks back to work on the game's own data.
  • Try ItThe first experiment is the proof of the standard: change the code word and all three forms change together (zoo → z = 26 = a different color). The second experiment introduces the new block contains, which reports true or false. Point out that contains answers a yes/no question, while item # of answers "which position?". In the third experiment, "hz" pays nothing because it is 2 letters long and "hat" is 3 — length of guards the bonus so a half-typed guess cannot win.
  • PlanThe IF diamond compares two lengths, so the bonus check only runs on a full-length guess. Ask: "Which arrow runs when the guess is still too short?" (No → keep catching apples.) Inside check guess the new contains block decides whether the guess holds the code letter. Note that the third lane is the Pico script from Chapter 12 — students add two blocks inside a loop they already wrote.
  • BuildThe list IS the data model — item 8 stores h. Encoding reads the position; decoding reads the item at that position. Step 11 gates the bonus on length, so a guess is only judged once it is as long as the code word. Push the point that the bonus size, Pico's color, and the letter are all the same code. Change word to zoo and every form changes at once.