Lesson 10: If/Else: Conditionals with Cards


This lesson demonstrates how conditionals can be used to tailor a program to specific information. We don’t always have all of the information we need when writing a program. Sometimes you will want to do something different in one situation than in another, even if you don't know what situation will be true when your code runs. That is where conditionals come in. Conditionals allow a computer to make a decision, based on the information that is true any time your code is run.


One of the best parts of teaching conditionals is that students already understand the concept from their everyday lives.

This lesson merges computer science into the real world by building off of their ability to tell if a condition is true or false. Students will learn to use if statements to declare when a certain command should be run, as well as if / else statements to declare when a command should be run and what do run otherwise. Students may not recognize the word conditionals, but most students will understand the idea of using "if" to make sure that some action only occurs when it is supposed to.


Warm Up (20 min)

Main Activity (20 min)

Wrap Up (15 min)

Assessment (5 min)

Extended Learning

View on Code Studio


Students will be able to:

  • Define circumstances when certain parts of a program should run and when they shouldn't.
  • Determine whether a conditional is met based on criteria.
  • Traverse a program and predict the outcome, given a set of input.


  • Watch the Conditionals with Cards - Lesson in Action Video.
  • Gather decks of cards or something similar.
  • One Conditionals with Cards Sample Program - Teacher Prep Guide for the class to look at.
  • Print one Conditionals with Cards - Assessment for each student.
  • Make sure every student has a Think Spot Journal - Reflection Journal.


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

For the Teachers

For the Students


  • Conditionals - Statements that only run under certain conditions.


Report a Bug

Teaching Guide

Warm Up (20 min)


This lesson has one new and important word:

Conditionals - Say it with me: Con-di-shun-uls

Statements that only run under certain conditions.


  • We can start this lesson off right away
    • Let the class know that if they can be completely quiet for thirty seconds, you will do something like:
      • Sing an opera song
      • Give five more minutes of recess
      • Do a handstand
    • Start counting right away.
    • If the students succeed, point out that they succeeded, so they get the reward.
    • Otherwise, point out that they were not completely quiet for a full thirty seconds, so they do not get the reward.
  • Ask the class "What was the condition of the reward?"
    • The condition was IF you were quiet for 30 seconds
      • If you were, the condition would be true, and you would get the reward.
      • If you weren't, the condition would be false, so the reward woud not apply.
    • Can we come up with another conditional?
      • If you can guess my age correctly, the class can give you applause.
      • If I know an answer, I can raise my hand.
      • What examples can you come up with?
  • Sometimes, we want to have an extra condition, in case the "IF" statement is not true.
    • This extra condition is called an "ELSE" statement
    • When the "IF" condition isn't met, we can look at the "ELSE" for what to do
      • Example: IF I draw a king from this deck of cards, everybody claps. Or ELSE, everyone says "Awwwwwwe."
      • Let's try it. (Draw a card and see if your class reacts appropriately.)
    • Ask the class to analyze what just happened.
      • What was the IF?
      • What was the ELSE?
      • Which condition was met?
    • Believe it or not, we have even one more option.
      • What if I wanted you to clap if I draw a 7, or else if I draw something less than seven you say "YAY," or else you say "Awwwwwwwe"?
        • This is why we have the terms If, Else-If, and Else.
        • If is the first condition
        • Else-If gets looked at only if the "If" isn't true.
        • Else gets looked at only if nothing before it is true.

Now let's play a game.

Main Activity (20 min)

Conditionals with Cards Sample Program - Teacher Prep Guide


  • Create a few programs with your class that depend on things like a card's suit, color, or value to award or subtract points. You can write the program as an algorithm, pseudocode, or actual code.

Here is a sample algorithm:

if (CARD is RED)
    Award YOUR team 1 point

    Award OTHER team 1 point

Here is a sample of the same program in pseudocode:

If (card.color == RED){
    points.yours = points.yours + 1;

Else {
    points.other = points.other + 1;
  • Decide how you want to split your class into teams.
  • Each team should have a pile of cards (at least as many cards as team members) nearby.
  • Put one of your “Programs” up on the board for all to see.
  • Have the teams take turns drawing cards and following the program to see how many points they score in each round.
  • Play several times with several different programs to help the students really understand conditionals.

Once the class has had some practice, you can encourage students to nest conditionals inside one another. Make sure they understand that if the card is red, YOUR team is awarded 1 point, and then nothing else happens, since the condition was met:

If (CARD is RED)
    Award YOUR team 1 point

    If (CARD is higher than 9)
        Award OTHER team 1 point
        Award YOUR team the same number of points on the card

Here is the same program in pseudocode:

If (card.color == RED ){
    points.yours = points.yours + 1;
Else {
    if (card.value > 9){
        points.other = points.other + 1;
    Else {
        points.yours = points.yours + card.value;

Wrap Up (15 min)

Flash Chat: What did we learn?

Lesson Tip

Flash Chat questions are intended to spark big-picture thinking about how the lesson relates to the greater world and the students' greater future. Use your knowledge of your classroom to decide if you want to discuss these as a class, in groups, or with an elbow partner.

  • If you were going to code this up in Blocky, what would you need to add around your conditionals to let the code run more than one time? (A loop)
  • What other things do you do during the day under certain conditions?
  • If you are supposed to do something when the value of a card is more than 5, and you draw a 5, do you meet that condition?
  • Notice that conditions are either "True" or "False." There is no assessment of a condition that evaluates to "Banana."
  • When you need to meet several combinations of conditions, we can use something called "nested conditionals."
    • What do you think that means?
    • Can you give an example of where we saw that during the game?
  • What part of that game did you like the best?


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?
  • What is a conditional? How did you use a conditional today?
  • What are some of the conditionals you used today? Can you come up with some more that you would use with a deck of cards?

Assessment (5 min)

Conditionals with Cards - Assessment

Hand out the assessment worksheet and allow students to complete the activity independently after the instructions have been well explained. This should feel familiar, thanks to the previous activities. Here's a Conditionals with Cards - Assessment Video to watch as a guide.

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."


  • Break students up into pairs or small groups.
  • Have them write if statements for playing cards on strips of paper, such as:
    • the suit is clubs
    • the color is red
  • Have students create similar strips for outcomes.
    • Add one point
    • 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?
  • Levels
  • 1
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Standards Alignment

View full course 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.6 - Attend to precision
  • MP.7 - Look for and make use of structure
  • MP.8 - Look for and express regularity in repeated reasoning

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.