Code Jumper Curriculum: Lessons, Lesson 11 Selection and Random
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 random values
Expected Outcomes
- All students: Be able to describe what selection with random values is
- Most students: Be able to recreate programs that use selection and random values
- Some students: Be able to create original programs that use selection, random values, and loops
Lesson Plan Structure
- Unplugged Activity
- Guided Code Jumper Activity
- Exploration
- Standards and Check for Understanding
Resources
- Code Jumper Tutorial Videos
- Code Jumper App: https://www.youtube.com/watch?v=vg72YPz6CWY
- The Hub: https://www.youtube.com/watch?v=KGb51PW9zJQ&lis=
- Play and Pause Pod: https://www.youtube.com/watch?v=446jCw8qcDI&t=
- Selection and Merge Pod: https://www.youtube.com/watch?v=Lx7EnNcjUrU
- Plugs: https://www.youtube.com/watch?v=hTy8moSohlE
- Loop Pod: https://www.youtube.com/watch?v=EFKbKLlD3HI
- Code Cards
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.)
- Random Value: A value that changes in a computer program depending upon the possible outcomes of the programming sequence (Compare to: Rolling dice)
Unplugged Activity
Objective
Introduce the idea of a selection structure and random values in computer programming and how students will apply it to their own program.
Vocabulary
- Random Value: is a value chosen by chance from some specified group of values. The value is not known until it has been generated.
Materials
A set of five tactile dice per student (Put dice in small, snack-sized bags for easy distribution.)
Random Value Counting Page (An example is at the end of the lesson.)
Instructions
- Divide students into groups of three to four. Distribute the Random Value Counting Page to each player. It can also be distributed electronically or in the Computer Science Journals.
- Explain to students that they will be playing a dice game with their small group and will keep track of the random values of their dice on their Random Value Counting Page.
- Instruct students to listen to the directions. The teacher may also want to model how to play.
- Directions for playing “Random Values”
- For Game #1: One player in the group calls out a number between one and six.
- Each player rolls all of the dice from their bag. This counts as roll number one.
- Any dice that match the number chosen can be set aside.
- Players roll all of the dice that did not match the chosen number and count that as roll number two.
- Players repeat this process until all dice are showing the chosen number.
- Players keep track of the number of rolls it takes them on their Random Value Counting Page.
- When all players have finished round one, a different player calls out a number between one and six and the group repeats this process.
- For example, if the student chooses the number 5, then they keep rolling all the dice trying to get each one to be the number 5. Therefore, the number of dice that are being rolled will decrease until finally they have all dice showing the same number. Students will record the number they are trying to get.
Game options: The teacher can decide if there is a winner each time. The student with the fewest number of rolls is declared the winner.
- Directions for playing “Random Values”
- Once all groups have completed their games and recorded their results, have them work together to come up with three observations about the data they collected on the Random Value Counting Page.
- Instruct students to write three of their group observations in their Computer Science Journals.
- Ask each small group to choose one group member to share their observations with the class. As groups share, the teacher will collect the observations.
Closure
Review with students the definition of random value. Help them make the connection that in the dice game the random value was the number of rolls it took to get all the dice to show the same number. Ask students to make inferences about random values in our world.
Code Jumper Guided Activity
Objective
Students will be able to develop programs that use selection and random values.
Vocabulary
Random Value: is a value chosen by chance from some specified group of values. The value is not known until it has been generated.
Materials
- Code Jumper Kit
- Play pods
- Selection pod
- Merge pod
- Random plug
Instruction
- Instruct students to take 4 Play pods, 1 Selection pod, 1 Merge pod, and the Random plug out of the kit.
- Review the Selection pod and the Merge pod. Explain that we use selection to decide which path a program will take, like coming to a fork in the road and deciding to go one way or the other. The Merge pod brings the program back together, like two paths becoming one.
- Ask students to connect the Selection pod to a thread on the Hub. Next, add one Play pod to each of the ports adjacent to the spokes on the Selection pod. Students can select whatever Sound Set they would like, making sure that each sound is different.
- Explain that both dials on the Selection pod can be set to any value between 1 and 8, and that if the statement is true, the program will choose the path of the two-spoke dial. If the statement is false, the program will choose the path of the three-spoke dial.
- Ask students to set the value for each dial on the Selection pod and predict which path the program will take. Repeat this task several times until the students understand the concept.
- Introduce the Random plug. Ask students to remove the Random plug from the Code Jumper Kit. The Random plug is similar to the Constant plug, but instead of having a fixed value, the Random plug generates a random value between 1 and 8 each time the program runs. Explain that a random value is a number that is randomly generated by a computer. This is similar to rolling dice, as you do not know what value you will get.
- Give students time to create a program using the Selection pod. The students should create a program that contains the Hub, 4 Play pods, the Selection pod, the Merge pod, and (optionally) the Pause pod. Students can use a Sound Set of their choosing. Remind students to debug their programs.
- Ask students to record their code in their Computer Science Journals. Draw their attention to how the statement is read when the Selection pod is connected. Ask students why END IF is important (Expected response: IF is the end of the conditional statement).
- Have students insert the Random plug into the two-spoke dial on the Selection pod without pressing Play. Draw their attention to how the statement is read when the Random plug is inserted (Expected response: the word random will appear in the first line of the IF statement.
- Then, ask students to set the three-spoke dial to 3 and predict what might happen when they press Play. Ask students to write their prediction in their Computer Science Journals. (Expected response: If the statement is true, the program will choose the path of the two-spoke dial. If the statement is false, the program will choose the path of the three-spoke dial.)
- Ask students to run the program several more times so they see that the value on the two-spoke dial changes when they use the Random plug.
Closure
- Ask students to explain what selection is and to give an example of how they used it in this lesson.
- Ask students what the Random plug does and to give an example of how they used it in this lesson.
Exploration
Objective
Students will create a story program with multiple endings.
Vocabulary
- Random Value: is a value chosen by chance from some specified group of values. The value is not known until it has been generated.
Materials:
- Code Jumper Kit: Hub, Play pods, Loop pods, Pause pods, Selection pod, Merge pod
- Random and Selection Code Card 1: Helen’s Story with Loop
- Random and Selection Code Card 2: Helen’s Story with Loop and Random Plug
- Helen’s Story Card 1
- Helen’s Story Card 2
Instruction
- Give students a copy of Selection and Random Code Card 1: Helen’s Story With a loop.
- Ask students to create the program for Helen’s Story using Code Card 1: Helen’s Story with a loop. Prompt students to think about how to bring a program back together after the Selection pod in a program. (Expected response: Use the Merge pod.)
- Ask students to play the program and see which path the Selection pod took. Ask students: What would you need to change to take the other path of the Selection pod? (Expected response: Change the dials on the Selection pod.) Give the students a few minutes to run the programs while changing the dials.
- Ask students: How do you make the program repeat? (Expected response: use a loop.)
- Ask students to add the program they made inside a loop and set the Loop pod to loop four times.
- Have students find the Random plug in the kit. Remind students that the Random plug generates a random value between 1 and 8 each time the program runs. In this program it is being used in the Selection pod, but it can also be used other Commands pods as well.
- Insert the Random plug into the two-spoke dial on the Selection pod and set the three-spoke dial to 4.
- In their Computer Science Journals, have students record how the story ends for the four times that it is played in the loop.
- Example:
Loop Ending: Number Two-spoke = 1 Three-spoke = 2 1 2 3 4 Second run-through 1 2 3 4
- Example:
- Change the value on the three-spoke dial and see if that changes the result and try a few more runs. Record in the Computer Science Journal.
- Distribute Selection and Random Code Card 2: Helen’s Story With a loop and Random plug. Students will insert the Random plug into the two-spoke dial of the Selection pod and set the three-spoke dial to 4. Tip: setting the three-spoke dial to 4 increases the chances of hearing both stories.
Closure
- Ask students: Did you notice a difference when the three-spoke dial was changed from 4? Did you hear an ending more frequently? Why do you think that is?
- Ask students: Why would using the Random plug be useful when creating a program?
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
Ask students to write a scenario in their Computer Science Journals where a random selection is made (Example: Pulling a certain type of candy out of a bag)
Check for Understanding | Completed |
---|---|
Students can describe what happens when a selection is made that is random. | Yes / No |
Code Cards for Selection and Random Lesson
Student Selection and Random Code Card 1: Helen’s Story With a Loop
- Sound category: Sample Sounds
- Sound Set: Helen’s Story
THREAD 2 Helen’s Story
LOOP 4 times
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 5>8
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
PAUSE for 1 beat
END LOOP
END THREAD
Student Selection and Random Code Card 2: Helen’s Story With Loop and Random plug
- Sound category: Sample Sounds
- Sound Set: Helen’s Story
THREAD 1 Helen’s Story
LOOP 4 times
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 random > 4 then
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
PAUSE for 1 beat
END LOOP
END THREAD
Random Value Counting Page Player Card
Player #1: Number of Rolls | Player #2: Number of Rolls | Player #3: Number of Rolls | Player #4: Number of Rolls | |
Game #1 Value: | ||||
Game #2 Value: | ||||
Game #3 Value: | ||||
Game #4 Value: |
For more resources, visit codejumper.com
Copyright © 2020
1839 Frankfort Avenue
Louisville, Kentucky 40206
502-895-2405 • 800-223-1839