image

Code Jumper Curriculum: Lessons, Lesson 10 Selection and Conditionals

American Printing House for the Blind

Code Jumper Curriculum: Lessons

Copyright © 2020 American Printing House for the Blind

All rights reserved. No part of this publication may be reproduced, stored in retrieval system, or transmitted in any form or by any means, except as expressly permitted under copyright law, without written permission of the publisher.

Published by American Printing House for the Blind

1839, Frankfort Avenue, Louisville, KY 40206

www.aph.org | [email protected]

OVERVIEW

LESSON OBJECTIVES

Students will:

  • Be able to develop programs that use selection and conditional statements

EXPECTED OUTCOMES

Students will:

  • All students: Be able to describe selection with conditional statements is
  • Most students: Be able to recreate programs that use selection with conditional statements
  • Some students: Be able to create original programs that use selection, conditional statements, and loops

LESSON PLAN STRUCTURE

  • Unplugged Activity
  • Guided Code Jumper Activity
  • Exploration
  • Standards and Check for Understanding

RESOURCES

KEY VOCABULARY

  • Selection: A structure in computer programming where, if a question is asked, the program decides what to do next based upon the answer. This is sometimes referred to as an if-then-else statement.
  • Conditionals: Statements that run only under certain conditions. For instance, if condition A is true, then perform this specific action.

UNPLUGGED ACTIVITY

OBJECTIVE

Introduce the idea of a selection structure and conditionals in computer programming and how they tell the program what to do based upon the conditions set.

VOCABULARY

  • If-else : to check and see if some expression is true, and if it is do something, otherwise do something else. Defining a statement that evaluates true or false.

MATERIALS:

  • One chair for each student
  • Question cards for teacher

INSTRUCTIONS

  1. Have students move their chairs into a circle. If necessary, leaving the chairs in place will work as well.
  2. Once chairs are set, have students sit in their own chair.
  3. Tell students that you are going to ask them several questions and if the answer is true for them, then they should make the corresponding sound and stand. If the answer is false for them, then they will stay silent and stay seated.
  4. Instruct students that once they are standing, they will remain standing if the next question applies to them, but if it does not apply to them then they need to sit back down in their chair.
  5. To determine how many students have true values, ask students to count off if they are standing.
  6. Ask the following questions (feel free to add more questions or tailor the questions to your own class):
    • Do you have tennis shoes on? Clap your hands and stand up.
    • Do you like to eat bananas? Clap your hands and stand up.
    • Have you ever lost a tooth at school? Clap your hands and stand up.
    • Have you ever been on a bus ride? Clap your hands and stand up.
    • Do you have a pet? Clap your hands and stand up.
    • Do you like to code? Clap your hands and stand up.
  7. After the activity, ask all students to sit down in their chairs and discuss what they observed when the answer to a question was true and what they observed when the answer to a question was false. (Goal: Students will correlate that when the answer was true, they stood up and clapped, and when the answer was false they sat down and remained quiet.
  8. Explain that in coding, this type of structure is called selection and that, depending on the answer to the question, an action takes place.
  9. Share with students that this structure can also be based on conditions in the form of if-else.
    • Example: If your shoe comes untied, then you tie it again. Example: If you have done your daily chores, then you can go and play with your friends.
    • Example: If you go to sleep at night, then you will not be tired in the morning.
  10. Encourage students to brainstorm other if-else statements they can think of in school or outside of school and share them with the class. Then run through the same activity, going through the students’ statements.

CLOSURE

Ask students to sit down again and get ready with an if-else statement. For example:

  • IF you rode the bus today, then clap your hands, ELSE make a honking sound. Students will be making noises together and it will be hard to tell how many are in each group.
  • Ask students to stop. Then, ask just the students who rode the bus to clap their hands. They can also count off to determine exactly how many rode the bus (touch the shoulder of each student who rode the bus). Repeat with the students who did not ride the bus.
  1. Tell students that they will be using Code Jumper to explore the selection structure and conditionals in computer programming.

GUIDED ACTIVITY

Objective

Students will learn about selection and conditional statements.

VOCABULARY

  • If-else: to check and see if some expression is true, and if it is do something, otherwise do something else. Defining a statement that evaluates true or false.
  • Conditional statement: a rule that will run when certain conditions are met, such as a true or false statement.

MATERIALS

  • Code Jumper Kit
  • Computer Science Journal
  • Selection and Conditional Code Card 1: Frere Jacques
  • Selection and Conditional Code Card 2: Helen’s Story
  • Two dice per group

INSTRUCTION

  1. Introduce the idea of a conditional statement to students. A conditional statement is a rule that will run when certain conditions are met, such as a true or false statement.
  2. In the Code Jumper Kit, there are green and white Command pods called the Selection pod and the Merge pod, respectively. Create a program to demonstrate using Selection and Conditional Code Card 1: Frere Jacques.

    image

    [Figure Caption: A photo of the Selection pod (left) and Merge pod (right)

    image

    [Figure caption:] In this photo of a Code Jumper Selection program, the Selection pod is connected to the Hub at Port 1, and one Play pod is connected to each of the Selection pod’s ports.
  3. Ask students to put both the Selection pod and the Merge pod on the desk.
  4. Explain that we use selection to decide which path a program will take, like choosing which path to take when there is a fork in the road. The Selection Pod will create a conditional statement with two values. Both dials can be set to any value between 1 and 8. If the statement is true, the program chooses the path of the two-spoke dial. If the statement is false, the program chooses the path of the three-spoke dial. This is an if-else statement.

    For example, if the two-spoke dial is set to 8, then the value and the dial with the three spokes is set to 5, the program will read “IF 8 is greater than 5”. This statement is true, so the pod attached to the port for the two-spoke dial will play when the program is run. If the two-spoke dial is set to 2 and the three-spoke dial is set to 7, the program will read “IF 2 is greater than 7”. This statement is false, so the pod connected to the three-spoke dial will run.

    image

    image

    [Figure Caption:] Two screenshots of the Code Jumper app are displayed at the top of this figure; each program has one thread. Under THREAD 1 Frère Jacques in the uppermost screenshot, the commands read, IF 8 is greater than 5; PLAY Ding, dang, dong for 1 times speed; ELSE; PLAY Sonnez les matines! for 1 times speed; END IF; the commands are followed by END THREAD. The next screenshot displays the same program as the first screenshot, except that its IF command reads, IF 2 is greater than 7. Below the screenshots is a photo of a Code Jumper program. A Selection pod is connected directly to the Hub at Port 1, and one Play pod is connected to each of the ports adjacent to the Selection pod’s two-spoke and three-spoke dials.
  5. Explain that the Merge pod is used to bring the program back together after the Selection pod options have been chosen. This allows students to add more command pods to the program after the IF/ELSE statement.

    image

    [Figure caption:] This is a photo of a Code Jumper Selection program. A Play pod is connected to the Hub at Port 1. The Selection pod is connected to that Play pod, and one Play pod is connected to each of the Selection pod’s ports. Each of these two Play pods is connected to one of the Merge pod’s two wires, and the last Play pod is connected to the Merge pod’s port.
  6. Ask students to create the program on Selection and Conditional Code Card 2: Helen’s Story.
  7. Using two dice, roll the first die to determine the number for the two-spoke dial value. Roll the second die to determine the value for the three-spoke dial.
  8. Ask students to write the numbers that were rolled in their Computer Science Journals. Ask students to determine or predict which path the program will take. Have students repeat the task three more times and record the outcomes in their Computer Science Journals.

CLOSURE

In their Computer Science Journals, have students reflect on where they see if-else statements in their everyday lives.

EXPLORATION

OBJECTIVE

Students will create a story by recording their own Sound Set and with multiple possible endings.

VOCABULARY

  • If-else: to check and see if some expression is true, and if it is do something, otherwise do something else. Defining a statement that evaluates true or false.

MATERIALS

Code Jumper Kit:

  • Hub
  • Eight Play pods
  • Selection and Merge pods
  • Pause pods (optional)

INSTRUCTION

  1. Review the Selection pod and Merge pod with students.
  2. In groups of two to three, students will create a story with a beginning, two to three middle lines, and two different endings.
  3. The story should be short, where each section becomes a line of code and a sound in a custom Sound Set. Have students create the story in their Computer Science Journals and write it out line-by-line.
  4. Once the story has been created, each group should record their own Sound Sets to add to the app. (See the video tutorials on how to create a custom Sound Set.)
  5. Once the sound sets have been created, ask students to write the code for the story in their Computer Science Journals.
  6. Ask students to then create their code in Code Jumper, debugging to ensure that the code is correct.
  7. Students should problem-solve and think about how they will set up the Selection pod to have each of the endings play.
  8. Ask students to use the dice to determine what they need to set the two- and three-spoke dials to have each ending play.

CLOSURE

  • Ask students: Where have they seen if-else statements in stories before?
  • Ask students: How does the story change? Will it always have the same ending?
  • Ask students: What would happen if you put the Selection pod in the middle of the story and used the Merge pod to continue on with the story? Would the story make sense?

STANDARDS AND CHECK FOR UNDERSTANDING

CSTA STANDARDS*

  • 1A-AP-12: Develop plans that describe a program’s sequence of events, goals, and expected outcomes.
  • 1B-AP-10: Create programs that include sequences, events, loops, and conditionals.

NATIONAL CURRICULUM OF ENGLAND** :

Key Stage 1:

  • Understand what algorithms are; how they are implemented as programs on digital devices; and that programs execute by following precise and unambiguous instructions
  • Create and debug simple programs
  • Use logical reasoning to predict the behavior of simple programs
  • Use technology purposefully to create, organize, store, manipulate and retrieve digital content
  • Recognize common uses of information technology beyond school
  • Use technology safely and respectfully, keeping personal information private; identify where to go for help and support when they have concerns about content or contact on the internet or other online technologies

Key Stage 2:

  • Design, write and debug programs that accomplish specific goals, including controlling or simulating physical systems; solve problems by decomposing them into smaller parts
  • Use sequence, selection, and repetition in programs; work with variables and various forms of input and output
  • Use logical reasoning to explain how some simple algorithms work and to detect and correct errors in algorithms and programs
  • Use search technologies effectively, appreciate how results are selected and ranked, and be discerning in evaluating digital content
  • Use technology safely, respectfully and responsibly; recognize acceptable/unacceptable behavior; identify a range of ways to report concerns about content and contact.

CLOSING ACTIVITIES AND CHECK FOR UNDERSTANDING

Students can play a game of “would you rather” using if-else statements. In the Computer Science Journal ask students to write down at least three if-else statements and then, in pairs, present the statements to a partner.

Check for Understanding Completed
Student can describe an if-else statement and a scenario where it can be used. Yes / No

LESSON 10: SELECTION AND CONDITIONAL CODE CARDS

TEACHER CODE CARDS

Selection and Conditional Code Card 1:

    ample program set up and run by teacher: Frere Jacques
    • Sound category: Sample Sounds
    • Sound Set: Frere Jacques

THREAD 1 Frere Jacques

IF 8>5

PLAY Ding, dang, dong for 1 times speed

ELSE

Play Sonnez les matines! For 1 times speed

END IF

END THREAD

STUDENT CODE CARDS FOR SELECTION AND CONDITIONALS LESSON

Selection and Conditional Code Card 2: Helen’s Story

  • Sound category: Sample Sounds
  • Sound Set: Helen’s Story

THREAD 1 STORY

PLAY Helen is looking for her friends for 1 times speed

PLAY She thinks they might be in the for 1 times speed

PLAY Haunted house for 1 times speed

PLAY She opens the door for 1 times speed

IF 2>7

PLAY Her friends jump out and yell surprise! for 1 times speed

ELSE

PLAY She sees a ghost and screams! for 1 times speed

END IF

END THREAD

image

For more resources, visit codejumper.com

Copyright © 2020

image

1839 Frankfort Avenue

Louisville, Kentucky 40206

502-895-2405 • 800-223-1839

www.aph.org[email protected]