# Lesson 11: Harvesting Crops with Loops

## Overview

Students loop new actions in order to help the harvester collect multiple veggies growing in large bunches.

## Purpose

In this lesson, students will use loops to repeat actions like harvesting pumpkins. New patterns will emerge and students will use creativity and logical thinking to determine what code needs to be repeated and how many times.

## Objectives

### Students will be able to:

• Write a program for a given task which loops a single command.
• Identify when a loop can be used to simplify a repetitive action.
• Employ a combination of sequential and looped commands to move and perform actions.

## Preparation

• Play through the puzzles to find any potential problem areas for your class.
• Make sure every student has a journal.

## Vocabulary

• Loop - The action of doing something over and over again.
• Repeat - To do something again.

# Teaching Guide

## Warm Up (5 - 10 min)

### Introduction

At this point, students have only used loops in the Maze puzzles. Those puzzles focused on looping movement instructions. This stage will use loops to pick up multiple items in the same spot.

• What are some other elements of our programs that could benefit from loops?
• Harvester puzzles can have lots of items in one spot. How can we use loops to pick up any number of them with just two blocks?

## Main Activity (30 min)

### Online Puzzles

When students are using loops to repeat an action (such as harvesting pumpkins), encourage them to think about the movements before and after that action. Could those actions be brought into the loop as well?

## Wrap Up (10 min)

### Journaling

Having students write about what they learned, why it’s useful, and how they feel about it can help solidify any knowledge they obtained today and build a review sheet for them to look to in the future.

#### Journal Prompts:

• What was today’s lesson about?
• How did you feel during today’s lesson?
• Give two examples of when you used loops in your code.
• What else could a farmer harvest? Draw the code block that you would need to harvest that item.

## Extended Activity

Use these activities to enhance student learning. They can be used as outside of class activities or other enrichment.

Harvesting Supplies

• Let students create piles of school supplies at their desks (pencils, erasers, etc.)
• Have their partners figure out how a harvester would walk from pile to pile, collecting each group of items along the way.
• Share the programs with the rest of the class.
• The Harvester
• 1
• (click tabs to see student view)
View on Code Studio

### Student Instructions

View on Code Studio

### Student Instructions

Loops can be used to repeat more than moves.

Use loops to collect all four of the pumpkins.

View on Code Studio

### Student Instructions

Can you combine two different loops to move toward the pumpkins, then collect them all?

View on Code Studio

### Student Instructions

Collect all of the pumpkins.

View on Code Studio

### Student Instructions

Now there is corn growing, too!

Collect all of the corn and all of the pumpkins.

View on Code Studio

### Student Instructions

Collect all of the corn and all of the pumpkins.

View on Code Studio

### Student Instructions

Collect all of the corn and all of the pumpkins.

View on Code Studio

### Student Instructions

Collect all of the corn and all of the pumpkins.

• Challenge
• 9
• (click tabs to see student view)
View on Code Studio

### Student Instructions

Challenge: Collect all of the corn and all of the pumpkins.

You can complete this challenge any way you want, but it will either take a lot of work or a lot of thinking!

View on Code Studio

### Student Instructions

Collect all of the corn and all of the pumpkins.

View on Code Studio

### Student Instructions

Collect all of the corn and all of the pumpkins.

View on Code Studio

### Student Instructions

Collect all of the corn and all of the pumpkins.

• Predict
• 13
• (click tabs to see student view)
View on Code Studio

### Student Instructions

Look closely at the code below. How many pumpkins will the farmer collect after you click "Run"?

4

12

15

I don't know.

View on Code Studio

### Student Instructions

View on Code Studio

### Student Instructions

Collect all of the lettuce. Avoid the trees and fields!

## Standards Alignment

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 1A-AP-09 - Model the way programs store and manipulate data by using numbers or other symbols to represent information.
• 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-14 - Debug (identify and fix) errors in an algorithm or program that includes sequences and simple loops.