Write and Evaluate Conditional Statements
In this lesson, students will learn to evaluate and write conditional statements, a structure used across coding languages. Conditional statements tell a program to carry out different actions depending on whether a condition is true or false. Students will first practice determining whether conditions are true and carrying out actions accordingly. They'll then write their own conditional statements and evaluate statements to predict the outcome of programs.
If your students are young or this lesson is their first exposure to the concept of conditionals, you may want to begin by using the first verse of the song and return to the second verse later. The first verse introduces the concept of conditionals and provides an example of the concept in daily life. The second verse walks through an example of a conditional from video or computer game code and introduces another piece of this concept, the "else if condition." The sequence below provides suggestions for adapting the lesson depending on your students' grade level and familiarity with conditionals.
If you've used this lesson plan with your students as part of Hour of Code, click here: I’m finished with my Hour of Code!

Objectives
- Define conditionals as statements that are carried out when certain criteria are met
- Determine whether or not a condition is true and carry out actions accordingly
- Write conditional statements, defining criteria for when a program should take certain actions
- Evaluate conditional statements and predict the outcome, given an input
Common Core State Standards
- CCSS.ELA-LITERACY.SL.3.3
- CCSS.ELA-LITERACY.W.4.2.D
- CCSS.ELA-LITERACY.W.5.2.D
- CCSS.ELA-LITERACY.RST.6-8.4
- CCSS.ELA-LITERACY.RST.6-8.7
- CCSS.ELA-LITERACY.W.6.2.D
Additional Standards
- Next Generation Science Standards
Products Created
- Completed Conditionals activity sheet
- Original conditional statements
- Predictions of the outcomes of peers' conditional statements
Time
1-2 class periods
Sequence
-
Introduce the concept of conditionals for the class by picking one student's name. Say, If your name is [student name], raise one hand. If that's not your name, sit on both of your hands. You can change the action of raising hands to anything that works in your classroom. Explain that this student raised his/her hand because it was true that [student name] was his/her name. The other students did not raise their hands because it was false. Tell students that they're going to learn about a coding concept called conditional statements, which allow a program to take different actions depending whether certain criteria are met.
-
Play the Flocabulary Conditionals video until the timecode 1:58.
-
Turn on Discussion Mode and watch the first half of the video again. Discussion Mode provides questions that check for understanding of the concept and encourage critical thinking and discussion.
-
If your students are comfortable with the concepts of "if" and "else" within conditional statements, you can turn off Discussion Mode and play the second half of the video, which provides an example of a conditional statement in the code for a video game. Or, you can explain to students that sometimes, when the if condition is false, the program might check another condition before it moves on to the else. This condition is called else if. A program can have as many else if conditions as you'd like. Demonstrate an else if condition for students by repeating the name exercise from Step 1, this time picking two additional student names and saying, "If your name is [student name], raise one hand. Else if your name is [additional student name], raise both hands. Else if your name is [second additional student name], nod at me. Else, sit on both of your hands."
-
Check for students' understanding by providing a few more conditional statements that students have to evaluate and act upon accordingly. For example:
- If it's raining outside, snap once. Else, clap twice.
- If there are an odd number of students in the class, say "We're odd!" Else, say "We're even!"
- If your birthday is in February, look to your left. Else, look to the right.
You can add else if conditions to these statements if you've chosen to include that in the lesson.
-
Pass out the Conditionals worksheet and have students completes Parts 1 and 2 in groups or individually. Part 2 includes bonus questions involving else if conditions that you can skip if you'd like.
-
If you have included information on else if in the lesson, come back together as a class and walk through the example problem for Part 3. In this section, students are given conditional statements and inputs for a program, and they have to run through the conditional and determine the outcome of the program. Have students complete the rest of Part 3 in groups or individually.
-
Come back together as a class and provide students with one scenario at a time. For example:
- You're playing a game where you choose M&Ms from a bag, and you win and lose points depending on what color they are.
- An exercise app will play different music depending on how fast you're running
- A program sorts people into different groups depending on when their birthdays are
- You have free time at school, and you do different activities depending on the weather.
For each of these scenarios, have students individually write the if condition and action, the else action and optionally the else if condition(s). For example, for the first scenario they may write, "If the M&M is green, gain 4 points. Else if the M&M is yellow, lose a point. Else, gain 2 points." Have them write an input for the conditional—for example, "M&M color is red." Then, have them swap papers with a partner and have the partner run through the conditional and determine what the outcome will be (here, "The player will gain 2 points").
Wrap Up/Extensions
- Have students complete Part 4 of the worksheet, in which they'll complete an interactive activity on Code.org called Bee Conditionals and return to the worksheet to flesh out one of the conditionals they created in the activity.
- Ask students to brainstorm things that they do in their everyday lives depending on whether certain conditions are true, and have them write out these conditional statements.
- Watch the fourth grade vocabulary video "Solve My Case," and have students identify the conditional statement in the first verse (Ayisha tells the narrator that if she sprints to the top of the mountain in less than a minute, he will have to pay her $20. Else, she will have to pay him $20.)
Primary Videos
Materials
- Flocabulary Conditionals video
- Conditionals activity sheet
- Paper and pencils