# Lesson 11: Conditionals in Bee

## Overview

Up until this point students have been writing code that executes exactly the same way each time it is run - reliable, but not very flexible. In this lesson, your class will begin to code with conditionals, allowing them to write code that functions differently depending on the specific conditions the program encounters.

## Purpose

After being introduced to conditionals in "Conditionals with Cards," students will now practice using them in their programs. The `if / else` blocks will allow for a more flexible program. The bee will only collect nectar if there is a flower or make honey if there is a honeycomb. Students will also practice and recognize a connection between `if / else` blocks and `while` loops in this set of puzzles.

## Objectives

### Students will be able to:

• Translate spoken language conditional statements into a program.
• Solve puzzles using a combination of looped sequences and conditionals.

## Preparation

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

## Vocabulary

• Conditionals - Statements that only run under certain conditions.

# Teaching Guide

## Warm Up (10 min)

### Introduction

Review the "Conditionals with Cards" activity with your students.

• What is a conditional statement?
• When is a conditional useful?
• What are some of the conditions you used in the last activity?

Now we're going to use conditionals with the Code.org bee to help him deal with some mysterious clouds. We don't know if his flowers have nectar or not, so we'll need to use conditionals to make sure that we collect nectar if it's there, but that we don't try to collect nectar from a flower that doesn't have any.

## Bridging Activity - Conditionals (15 min)

This activity will help bring the unplugged concepts from "Conditionals With Cards" into the online world that the students are moving into. Choose one of the following to do with your class:

### Unplugged Activity Using Paper Blocks

Print and cut out 2-3 `if / else` and blank action blocks from Unplugged Blocks (Courses C-F) - Manipulatives and pull out a deck of cards. Ask the class to come up with a couple of conditionals to use with the deck of cards like they did in "Conditionals with Cards." When the conditionals have been decided on as a class, fill in the blank part of the `if` block with the various card values that the kids came up with. Examples include "King of Hearts", "Even Numbered", or "Diamonds". Fill in the action blocks with the actions the students came up with. Make sure the students know the action blocks need to be directly under the `if` or `else` block. Below is an example.

Now shuffle the deck of cards and play "Conditionals with Cards" again. Flip through the deck card-by-card, reacting to cards if a conditional has been made for it.

### Preview of Online Puzzles

Pull up a puzzle from Course D, we recommend puzzle 9.

• Ask the class what the bee should do when it gets to the cloud.
• The bee should use a conditional to check for a flower or a honeycomb.
• Use the `if at flower / else` block. Ask the class what the bee should do if there's a flower. If there's not a flower, there will be a honeycomb. What should the bee do then?
• The bee should `get nectar` if there is a flower and `make honey` if there is a honeycomb.

Fill in the rest of the code and press `Run`. Discuss with the class why this worked.

## Main Activity (30 min)

### Course D Online Puzzles - Website

These puzzles might sprout some questions, so have the students work in pairs or implement the "Ask three before you ask me" rule (have the students ask three other peers for help before they go to the teacher.) This will spark discussions that will develop each student's understanding.

## 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 today's lesson make you feel?
• What conditionals did you use in your code today?
• What are some other conditionals a bee might use? Examples include:
• if there is a tree in front of me, buzz out of the way
• if my wing is hurt, rest on the ground
• if I see another bee, say "Hello!"

## Extended Learning

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

True/False Tag

• Line students up as if to play Red Light / Green Light.
• Select one person to stand in front as the Caller.
• The Caller chooses a condition and asks everyone who meets that condition to take a step forward.
• If you have a red belt, step forward.
• If you are wearing sandals, take a step forward.
• Try switching it up by saying things like "If you are not blonde, step forward."

Nesting

• Break students up into pairs or small groups.
• Have them write if statements for playing cards on strips of paper, such as:
• If the suit is clubs
• If the color is red
• Have students create similar strips for outcomes.
• Subtract one point
• Once that's done, have students choose three of each type of strip and three playing cards, paying attention to the order selected.
• Using three pieces of paper, have students write three different programs using only the sets of strips that they selected, in any order.
• Encourage students to put some if statements inside other if statements.
• Now, students should run through all three programs using the cards that they drew, in the same order for each program.
• Did any two programs return the same answer?
• Did any return something different?
View on Code Studio

### Student Instructions

View on Code Studio

### Student Instructions

Take a good look at the code below. What do you think will happen after you click "Run"?

The bee will move to the cloud and try to get nectar, no matter what.

The bee will move to the cloud and only try to get nectar if there is a flower underneath.

The bee will move to the cloud and then do nothing, no matter what.

I don't know.

View on Code Studio

### Student Instructions

More clouds!

Check underneath every cloud to see if it is hiding a flower before you get nectar.

Remember: Not all clouds hide the same thing!

View on Code Studio

### Student Instructions

You can only collect nectar from flowers, but you can check any space to see if there is a flower.

View on Code Studio

### Student Instructions

In this puzzle, we know that every flower has exactly one nectar, but the flowers aren't spaced evenly.

Get all of the nectar using as few blocks as possible.

View on Code Studio

### Student Instructions

View on Code Studio

### Student Instructions

"Now I just want to make honey."

Some of these clouds might have honeycombs under them. Be sure to check if a honeycomb is hiding behind each cloud!

View on Code Studio

### Student Instructions

View on Code Studio

### Student Instructions

Sometimes a cloud covers a flower, sometimes it covers a honeycomb!

Use the `ifelse` block to collect nectar at flowers and make honey at honeycomb.

View on Code Studio

### Student Instructions

Look carefully at the code below. What do you think will happen after you click "Run"?

The bee will get nectar at each flower and honey at each honeycomb.

The bee will try to get nectar from both flowers and honeycomb.

The bee will try to get honey from both flowers and honeycomb.

I don't know.

View on Code Studio

### Student Instructions

Challenge: There will be either a flower or a honeycomb under each of those clouds!

Collect nectar if there is a flower. Otherwise, make honey (because there is a honeycomb).

View on Code Studio

### Student Instructions

Collect all of the nectar or make all the honey. You can only collect nectar from flowers and make honey from honeycombs. Check any space to see if there is a flower or honeycomb.

View on Code Studio

### Student Instructions

Conditionals can be helpful, even when you know exactly what is in each spot!

Collect all of the nectar and make all of the honey.

## Standards Alignment

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

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

## Cross-curricular Opportunities

This list represents opportunities in this lesson to support standards in other content areas.

#### Common Core English Language Arts Standards

L - Language
• 3.L.6 - Acquire and use accurately grade-appropriate conversational, general academic, and domain-specific words and phrases, including those that signal spatial and temporal relationships (e.g., After dinner that night we went looking for them).
SL - Speaking & Listening
• 3.SL.1 - Engage effectively in a range of collaborative discussions (one-on-one, in groups, and teacher-led) with diverse partners on grade 3 topics and texts, building on others’ ideas and expressing their own clearly.
• 3.SL.3 - Ask and answer questions about information from a speaker, offering appropriate elaboration and detail.
• 3.SL.6 - Speak in complete sentences when appropriate to task and situation in order to provide requested detail or clarification.

#### Common Core Math Standards

MP - Math Practices
• MP.1 - Make sense of problems and persevere in solving them
• MP.2 - Reason abstractly and quantitatively
• MP.4 - Model with mathematics
• MP.5 - Use appropriate tools strategically
• MP.6 - Attend to precision
• MP.7 - Look for and make use of structure
• MP.8 - Look for and express regularity in repeated reasoning
OA - Operations And Algebraic Thinking
• 3.OA.3 - Use multiplication and division within 100 to solve word problems in situations involving equal groups, arrays, and measurement quantities, e.g., by using drawings and equations with a symbol for the unknown number to represent the problem.1

#### Next Generation Science Standards

ETS - Engineering in the Sciences
ETS1 - Engineering Design
• 3-5-ETS1-2 - Generate and compare multiple possible solutions to a problem based on how well each is likely to meet the criteria and constraints of the problem.