# Lesson 18: Functions in Farmer

## Overview

Students have practiced creating impressive designs in Artist and navigating mazes in Bee, but today they will use functions to harvest crops in Farmer. This lesson will push students to use functions in the new ways by combining them with `while` loops and `if / else` statements.

## Purpose

This lesson is meant to further push students to use functions in more creative ways. By also using conditionals and loops, students will learn there are many ways to approach a problem, but some are more efficient than others. These puzzles are intended to increase problem solving and critical thinking skills.

## Objectives

### Students will be able to:

• Recognize when a function could help to simplify a program.
• Use pre-determined functions to complete commonly repeated tasks.

## Preparation

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

## Vocabulary

• Function - A named group of programming instructions. Functions are reusable abstractions that reduce the complexity of writing and maintaining programs.

# Teaching Guide

## Warm Up (10 min)

### Introduction

At this point, your students should already be introduced to functions. Take this time to have them discuss the advantages and disadvantages of using functions in a program. Either have them pair share or discuss as a class. Try using examples of hard or easy puzzles in either Artist or Bee.

• When would you use a function?
• Why does a function help to simplify your program?
• Do you think functions make programming easier or harder? Why?

## Main Activity (30 min)

### Course E Online Puzzles - Website

Some puzzles will have a function pre-declaredfor the students to fill in. It may be helpful for the students to write the entire program without a function first, then determine where a function would be useful in the program.

It's important to make sure that every student is completing each puzzle with a dark green dot. If some of your students are struggling to simplify code and use functions, set up teams of expert students within your class to go around and answer questions.

Don't forget to provide pencils and paper to help students sketch out possible solutions.

## 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 did you feel about today's lesson?
• How do `while` loops and `if / else` statements help your program?