# Lesson 20: Conditionals & Loops in Harvester

## Overview

Students will practice `while` loops, `until` loops, and `if / else` statements. All of these blocks use conditionals. By practicing all three, students will learn to write complex and flexible code.

## Purpose

Practicing the use of conditionals in different scenarios helps to develop a student's understanding of what conditionals can do. In the previous lesson, students only used conditionals to move around a maze. In this lesson, students will use conditionals to help the farmer know when to harvest crops. New patterns will emerge and students will use creativity and logical thinking to determine the conditions where code should be run and repeated.

## Objectives

### Students will be able to:

• Nest conditionals to analyze multiple value conditions using if, else if, else logic.
• Pair a loop and conditional statement together.

## Preparation

Heads Up! Please make a copy of any documents you plan to share with students.

## Vocabulary

• Condition - A statement that a program checks to see if it is true or false. If true, an action is taken. Otherwise, the action is ignored.
• Conditionals - Statements that only run under certain conditions.
• Loop - The action of doing something over and over again.
• Repeat - Do something again
• While Loop - A loop that continues to repeat while a condition is true.

# Teaching Guide

## Warm Up (5 min)

### Introduction

Students shouldn't need as much of an introduction to concepts today because they have had practice with them in the previous lesson. Instead, you can share the story of the harvester.

The harvester is trying to harvest crops like pumpkins, lettuce, and corn. However, the farmer has forgotten where she planted these crops, so she needs to check each plant before harvesting.

## Main Activity (30 min)

### CSF Express Course - Website

Students will continue to work with `if / else` statements, `while` loops, and `until` loops. These puzzles are a bit more challenging, though, so encourage students to stick with them until they can describe what needs to happen for each program.

## Wrap Up (15 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 do you feel about today's lesson?
• How can you see conditionals being useful in programs?
• What if people only spoke in if/else statements? What would be some advantages and disadvantages of this?

## Standards Alignment

#### CSTA K-12 Computer Science Standards

AP - Algorithms & Programming
• 1B-AP-11 - Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.