This engaging, cross-curricular, two-day lesson is designed for students in grades 2-5. Students will combine their computer science knowledge of pseudocode and algorithms with their procedural writing skills to produce an algorithm for making the best peanut butter and jelly sandwich. Students will need to think efficiently like programmers while using a clear and precise writing style to create an algorithm that will hopefully give them the intended outcome: a delicious sandwich. On the second day, the teacher will actually make peanut butter and jelly sandwiches in class according to the students’ algorithms! For example, if the algorithm says, “put the peanut butter on the bread,” the teacher will literally place the jar of peanut butter on top of the loaf of bread to model just how precise programmers must be when writing code. Students will have an opportunity to practice their revision and editing skills by identifying and fixing bugs, a common coding problem.
Grades K-2 | 1A-AP-08 – Model daily processes by creating and following algorithms (sets of step-by-step instructions) to complete tasks. |
1A-AP-10 – Develop programs with sequences and simple loops, to express ideas or address a problem. | |
1A-AP-11 – Decompose (break down) the steps needed to solve a problem into a precise sequence of instructions. | |
1A-AP-12 – Develop plans that describe a program’s sequence of events, goals, and expected outcomes. | |
1A-AP-13 – Give attribution when using the ideas and creations of others while developing programs. | |
1A-AP-14 – Debug (identify and fix) errors in an algorithm or program that includes sequences and simple loops. | |
1A-AP-15 – Using correct terminology, describe steps taken and choices made during the iterative process of program development. | |
Grades 3-5 | 1B-AP-08 – Compare and refine multiple algorithms for the same task and determine which is the most appropriate. |
1B-AP-09 – Create programs that use variables to store and modify data. | |
1B-AP-10 – Create programs that include sequences, events, loops, and conditionals. | |
1B-AP-11 – Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. | |
1B-AP-13 – Use an iterative process to plan the development of a program by including others’ perspectives and considering user preferences. | |
1B-AP-15 – Test and debut (identify and fix errors) a program or algorithm to ensure it runs as intended. | |
1B-AP-17 – Describe choices made during program development using code comments, presentations, and demonstrations. |
2nd Grade | CCSS.ELA-Literacy.W.2.5 – With guidance and support from adults and peers, focus on a topic and strengthen writing as needed by revising and editing. |
CCSS.ELA-Literacy.W.2.8 – Recall information from experiences or gather information from provided sources to answer a question. | |
3rd grade | CCSS.ELA-Literacy.W.3.4 – With guidance and support from adults, produce writing in which the development and organization are appropriate to task and purpose. |
CCSS.ELA-Literacy.W.3.5 – With guidance and support from peers and adults, develop and strengthen writing as needed by planning, revising, and editing. | |
CCSS.ELA-Literacy.W.3.8 – Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories. | |
CCSS.ELA-Literacy.W.3.10 – Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences. | |
4th grade | CCSS.ELA-Litearcy.W.4.4 – Produce clear and coherent writing in which the development and organization are appropriate to task, purpose, and audience. |
CCSS.ELA-Literacy.W.4.5 – With guidance and support from peers and adults, develop and strengthen writing as needed by planning, revising, and editing. | |
CCSS.ELA-Literacy.W.4.8 – Recall relevant information from experiences or gather relevant information from print and digital sources; take notes and categorize information, and provide a list of sources. | |
CCSS.ELA-Literacy.W.4.10 – Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences. | |
5th grade | CCSS.ELA-Litearcy.W.5.4 – Produce clear and coherent writing in which the development and organization are appropriate to task, purpose, and audience. |
CCSS.ELA-Literacy.W.5.5 – With guidance and support from peers and adults, develop and strengthen writing as needed by planning, revising, editing, rewriting, or trying a new approach. | |
CCSS.ELA-Literacy.W.5.8 – Recall relevant information from experiences or gather relevant information from print and digital sources; summarize or paraphrase information in notes and finished work, and provide a list of sources. | |
CCSS.ELA-Literacy.W.5.10 – Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences. |
Students will be able to apply what they know about sequencing to write a pseudocode algorithm for a human task: making a peanut butter and jelly sandwich.
Students will be able to apply their revising and editing skills to fix any bugs in their pseudocode algorithms, so they function as intended.
Day 1: approximately 50-60 minutes
Day 2: approximately 55-80 minutes
• Building Blocks of Computer Science books, specifically Algorithms, Coding Languages, Logic in Coding, and Debugging
• Writing Paper (for drafting and publishing)
• Pencils
• Optional: Colored pencils for editing
• Optional: Sequencing Graphic Organizer (1 per student)
• Optional: Sequencing Sentence Stems (1 per student)
• Ingredients for peanut butter and jelly sandwiches, such as bread, peanut butter, jelly, plates, napkins, knives, cutting board, and any other special ingredients students may call out in their pseudocode algorithms (i.e., bananas, chocolate chips, etc.)
If your students are allergic to any of the food used in this lesson, please swap them for other ingredients. For example, students could list the steps for making an ice cream sundae.
To prepare for Day 2, read students’ pseudocode algorithms and pull out any examples that will help you demonstrate the need for clear, precise, and efficient steps in an algorithm.
This two-day lesson is best used after reading the Algorithms and Debugging texts or, for extension, after reading the Coding Languages and Logic in Coding texts.
Students should know that algorithms are step-by-step instructions that produce a specific outcome. Students should be able to recognize that algorithms are not only useful in computer science, but are also used in other situations like in mathematics or when providing someone directions.
Students should have a foundational knowledge of programming bugs including syntax, token, and logic errors. In addition, they should have a general understanding of how programmers identify and fix bugs.
Because students will engage in writing and editing, it would be beneficial for them to have some peer editing experience prior to participating in this lesson. If your students have not participated in peer editing before, consider doing a mini lesson on this first.
Students’ first draft of their directions, collected on Day 1
Students’ edits on their first draft, collected on Day 2
Students’ final written piece, collected on Day 2
Algorithm – a set of step-by-step instructions used to write computer programs; also used to solve math problems and other problems
Bug – an error in a program’s code that keeps the program from working the way it is intended
Condition – a statement that can be true or false; a program may tell a computer to run a piece of code if a certain condition is true
Function – a set of statements that works together to accomplish a specific goal
Logic – the rules of proper reasoning
Logic error – a bug that does not stop the program from working but causes it to do the wrong thing
Loop – a piece of code that causes part of a program to run over and over again
Programming language – a set of symbols and rules that programmers use to write computer programs
Pseudocode – a description of a computer program written in human language
Statement – a command or instruction for the computer
Syntax – the rules that make up the “grammar” of a programming language
Syntax error – a bug caused by improper syntax in the code
Token error – a bug caused when code includes a word or symbol not in the programming language
Variable – a value, or piece of information, that can change
For students who need more support with organizing their writing, consider providing them a copy of the Sequencing Graphic Organizer. You may also consider providing students with a copy of the Sequencing Supports to aid them in their writing process.
Consider the following extension opportunity: During the Application Activity phase of Day 2, have students identify and label the type of bugs they find when editing their writing. They can classify their bugs as syntax (S), token (T), or logic (L) errors by labeling them in a different colored pencil on their first draft. In addition, consider challenging these students to be more efficient with their code.
Challenge students who finish before their peers to write a related pseudocode algorithm for a modified type of peanut butter and jelly sandwich. For example, challenge students to describe the steps for just a peanut butter sandwich or a peanut butter and jelly sandwich with slices of bananas. Encourage students to apply what they know about variables, loops, and conditions here.
Consider pulling a small group of struggling writers to aid them in their use of the Sequencing Supports to edit their writing.
Time Guidelines:
Approximately 10-12 minutes
Teacher Actions
Begin by activating prior knowledge with a “brain dump.” During a brain dump, students are encouraged to write anything they think or wonder about related to a particular subject on a piece of scratch paper. Here, students will have 2 minutes to brain dump everything they know or wonder about algorithms. Challenge students to write the entire time.
When time is up, have students share what they brain dumped with a neighbor before calling on a few volunteers to share out. Consider picking specific students and responses to address any misconceptions. Use the following prompts to guide your sharing and discussion:
Explain to students that today they will have a chance to write their own algorithm for how to make the best peanut butter and jelly sandwich! Instead of writing this in a programming language, however, they will use pseudocode to create their algorithm. Depending on your students’ needs, consider reviewing the vocabulary terms programming language and pseudocode.
Time Guidelines:
Approximately 15-18 minutes
Teacher Actions
Reread pages 10 and 11 of the Algorithms text and review the idea that algorithms are a series of step-by-step instructions used to complete a task or achieve a goal.
Remind students that although programmers use programming languages like Scratch and C, today they will use pseudocode to write their instructions out line by line. Discuss the benefits and drawbacks of different languages such as pseudocode, programming language, and machine language. Different languages are best for different purposes, and, for today’s goal, it is best to use pseudocode written in human language.
Reread pages 14-17 of the Algorithms text and discuss the idea of efficiency. Efficient algorithms are those that complete the task correctly in the fastest way and those that use the least of a machine’s power. Discuss with students why efficiency is important in programming. Depending on your students’ learning needs, consider discussing how one could make sure their code is as efficient as possible.
Pose the task to students: Explain that today they will write an algorithm in pseudocode for how to make the best peanut butter and jelly sandwich. They will write each step on its own line, making sure to include all the details needed while also ensuring the algorithm is efficient.
Time Guidelines:
Approximately 15-20 minutes
Teacher Actions
Provide time for students to create their pseudocode algorithm for making the best peanut butter and jelly sandwich. Keep your students’ learning needs in mind and consider options for small group support as described in the differentiation considerations section of this lesson plan.
Encourage students to talk through their steps with a peer to see if anything is missing or whether steps need to be tweaked to produce the intended outcome.
Students should complete their pseudocode algorithm for making the best peanut butter and jelly sandwich by the end of this lesson.
Time Guidelines:
Approximately 5-10 minutes
Teacher Actions
Return to the whole group setting and discuss the writing process. Consider asking questions such as:
Explain to students that tomorrow we will have a chance to run our programs to see what, if any, bugs exist! Make sure to collect students’ writing before concluding this session so you can prepare for the second day of this lesson.
What went well?
What changes might be beneficial?
Reteaching Needs
Extension Needs
Time Guidelines:
Approximately 5-10 minutes
Teacher Actions
Begin by reviewing the previous lesson’s work with pseudocode and explain that today students will have the opportunity to test their code! They will simulate debugging a program by looking for any errors and editing, or fixing, them.
Review pages 28-29 of the Debugging book and discuss self-talk phrases students can use if and when they find bugs in their pseudocode algorithms. Remind students that even the best programmers make mistakes, and those mistakes provide great opportunities to learn and improve.
Time Guidelines:
Approximately 15-20 minutes
Teacher Actions
Use pages 12-25 of the Debugging text to review common types of programming errors:
Remind students that it is common to find bugs, or errors, in code and that good programmers develop ways to fix them so their programs run as intended.
Next, use the writing samples you prepared ahead of time to follow students’ algorithms for making the best peanut butter and jelly sandwich. Follow students’ directions exactly. Call on your rapport and relationships with students and have some fun here! If the algorithm says, “put the peanut butter on the bread,” literally place the jar of peanut butter on top of the loaf of bread. If the algorithm instructs you to “use the knife to cut the sandwich,” cut it into crazy shapes because the algorithm did not specify how the sandwich should be cut. Exaggerate a little and bring some theatrics! The goal here is twofold: 1. Students should realize that mistakes (bugs) happen frequently and should not cause bad feelings or stress and 2. Students should understand just how detailed, specific, and straightforward programmers must be when writing code. After watching you follow their algorithms, students should be motivated to fix any bugs they find within their pseudocode.
For an extension opportunity, or if your class is ready for the added rigor, see the Differentiation Consideration bullet point that encourages students to determine which type of bug (syntax, token, or logic) they identified.
Time Guidelines:
Approximately 15-20 minutes
Teacher Actions
Pair up students to apply the same process you modeled to their own writing. Students will read through each pseudocode line-by-line looking for and discussing potential fixes for any bugs. When explaining this portion of the task to students, draw attention to the connections between debugging a program and editing a piece of writing.
Provide students time to collaborate and edit with their peers.
Time Guidelines:
Approximately 15-20 minutes
Teacher Actions
Have students transition to the independent work setting to re-write their pseudocode algorithm with the bug fixes they discussed with their partner.
See the Differentiation Considerations section of this lesson plan for possible supports and extensions here.
Time Guidelines:
Approximately 5-10 minutes
Teacher Actions
Return to the whole group setting and discuss the process of debugging and fixing/editing their pseudocode algorithm. Consider asking questions such as:
Review the objectives by explaining that students recalled prior experiences to create a pseudocode algorithm for making the best peanut butter and jelly sandwich. Students also engaged in the editing process when they “debugged” their algorithms in order to make them run smoothly.
What went well?
What changes might be beneficial?
Reteaching Needs
Extension Needs