teacher note Teacher note: Conditionals with cards

A misconception that students have about conditionals is that both the statements or blocks under the if and else are executed each time. For instance:

1if x < 2:
2    print("Programming rules!")
4    print("This is great!")

Some students think that if x is 1 when the above code is run, the computer will print Programming rules!” and then continue to the else and print “This is great!”. In fact, only one of the statements is ever printed, never both.

Code.org has a great “unplugged” activity called Conditional with Cards which can help students learn the “conditional” execution of code.


Two teams take turns drawing from a deck of cards. Based on conditions like the card’s suit, color, or value, the teams can gain or lose points, depending on the “program” being run at the time. The game ends when either team reaches a set number of points, or when you run out of cards.

To prepare

1if Card is Red:
2    Award YOUR team 1 point
4    Award the OTHER team 1 point
1if the Card's value < 5:
2   Deduct 2 points from YOUR team
4    Deduct 2 points from the OTHER team


  1. Split the class into two teams, say, Team A and Team B. (More fun: have them choose their own team names!)

  2. Shuffle the cards and place the deck in the middle of the room.

  3. Put a “program” up on the board for all to see.

  4. Have the teams take turns drawing cards and “running” the program to see how many points they score each time (keep the score on the board).

  5. At different points in the game, change the program on the board. Do this several times, so students get practice with different types of conditionals.

Wrap up questions

You have attempted of activities on this page