Chapter 2
Module 4: Conditionals
Before you teach. . .
You may want to prepare the following before you implement this module in your classroom:
How to teach a lesson. . .
Table of Contents
Lessons
Explorations
Additional Resources
Module 4
Lesson 1
Introduction to Conditionals
What did we learn last time?
-What are variables?
-How did you use variables in Ozaria?
-What’s the difference between strings & numbers?
-How did you use findNearestFriend in Ozaria?
Today’s Journey
Warm-Up: Conditionals
Explore using Pseudocode
Play Ozaria: Explore the city of Xing’Chen
Optional Extension: Design a Level
Conditionals
Conditionals
If
Then
condition
action
We use conditionals to help us plan and make decisions. We check a condition to see if it’s true or false. If the condition is true, then we perform an action.
It is raining.
Bring an umbrella!
Conditionals
condition
indented
action
Programs use conditionals to make decisions. This allows you to use the same program even if conditions change.
IF there is a RIVER
hero jumpRight
IF there is NO RIVER
hero moveRight
Concept Check: Conditionals
Fill out the table using pseudocode
IF | Condition | THEN | Action |
There is a door | Use the door | ||
There is a pit | Jump over the pit | ||
| | ||
| | ||
| |
IF there is a DOOR
hero USES DOOR
�IF [condition]
[action]
Independent Practice
Independent Practice
Play Ozaria
Start with Cinematic: Welcome to the City�and stop after you finish Challenge Level: The Suspect
Extension Activity: Design a Map
Use the link provided by your teacher to complete this�activity.
Need Help?�Always try it once & try using the troubleshooting guide first. If you still need help after that, then reach out to a classmate or the teacher.
Check-In
What did you discover?
Chapter 2, Module 4, Lesson 1
What I did:
-How far did you get in Ozaria? What was your favorite part?
What I noticed:
-What did you notice as you played through the game?
-Did you discover or learn something new?
What was challenging?�-Was something confusing about the story or the levels?
-Do you need more practice on a specific part of the code or the game?
Module 4
Lesson 2
Comparators & Conditionals
What did we learn last time?
-What are conditionals?
-How did you use conditionals in Ozaria?
-What’s pseudocode?
-How happened in the story of Ozaria?
Today’s Journey
Warm-Up: Comparators & Conditionals
Exploring Flowcharts & Conditionals
Play Ozaria: Explore the city of Xing’Chen
Optional Extension: Design a Conditional Card Game
Comparators & Conditionals
Comparators
How do we use comparators in math?
Is 3 < 5?
Is 3 > 5?
Comparators & Conditionals
comparator condition
IF distance to enemy < 4
Comparators can be used in conditionals too
hero moveRight
TRUE
FALSE
hero sneakRight
Comparators & Conditionals
Only happens if distance < 4
Only happens if distance > 4
Will always happen after the hero sneaks right or moves right
TRUE
FALSE
The way conditionals work is a little more complicated...
IF distance < 4
hero sneakRight
IF distance > 4
hero moveRight
hero jumpRight
IF distance to enemy < 4
hero moveRight
TRUE
FALSE
hero sneakRight
IF distance to enemy > 4
hero jumpRight
Concept Check: Comparators
Let’s play a card game using comparators and conditionals!
Draw a Card
card = get VALUE of CARD
IF card < 7
Player A gets 1 POINT
�IF [condition]
[action]
TRUE
FALSE
IF card value < 7
1 point for Player B
TRUE
FALSE
1 point for Player A
IF card value > 7
Player A or B draws a card
Card Values
- Ace = 1
- 2-10 = 2-10
- Jack = 11
- Queen = 12
- King = 13
Go back to the beginning of the diagram.
Independent Practice
Independent Practice
Play Ozaria
Start with Intro: The Thief�and stop after you finish Cinematic: Fighting Back
Extension Activity: Design a Conditional Card Game
Use the link provided by your teacher to complete this�activity.
Need Help?�Always try it once & try using the troubleshooting guide first. If you still need help after that, then reach out to a classmate or the teacher.
Check-In
What did you discover?
Chapter 2, Module 4, Lesson 2
What I did:
-How far did you get in Ozaria? What was your favorite part?
What I noticed:
-What did you notice as you played through the game?
-Did you discover or learn something new?
What was challenging?�-Was something confusing about the story or the levels?
-Do you need more practice on a specific part of the code or the game?
If/Else Conditionals
Module 4
Lesson 3
What did we learn last time?
-What are comparators?
-How did you use flowcharts to plan out conditionals?
-How did you use comparators and conditionals in Ozaria?
-How happened in the story of Ozaria?
Today’s Journey
Warm-Up: If/Else Conditionals
Exploring Flowcharts & If/Else Conditionals
Play Ozaria: Defeat enemies with new spells
Optional Extension: Design a Conditional Story
If/Else Conditionals
If/Then Conditionals
How did we use a flowchart to map these conditionals?
TRUE
FALSE
IF distance to enemy < 4
hero moveRight
TRUE
FALSE
hero sneakRight
IF distance to enemy > 4
hero jumpRight
If/Else Conditionals
If/Then
If/Else
What do you notice is different between the two flowcharts?
IF distance to enemy < 4
TRUE
ELSE
hero sneakRight
hero jumpRight
hero moveRight
TRUE
FALSE
IF distance to enemy < 4
hero moveRight
TRUE
FALSE
hero sneakRight
IF distance to enemy > 4
hero jumpRight
If/Then
If/Else
Programming Tips
We are always looking for new ways to make our code faster, efficient, and error proof.
We achieve this with structured programming.
Structured programming uses reusable elements, like variables, to make a program clearer and easy to update.
With regular programming, although it requires less planning ahead, a program is prone to errors and hard to update.
Structured
Regular
TRUE
FALSE
IF distance to enemy < 4
hero moveRight
TRUE
FALSE
hero sneakRight
IF distance to enemy > 4
hero jumpRight
IF distance to enemy < 4
TRUE
ELSE
hero sneakRight
hero jumpRight
hero moveRight
If/Else Conditionals
If/Then
If/Else
Only happens if distance < 4
ELSE this happens if the condition is false
Will always happen after the hero sneaks right or moves right
Let’s see how if/else conditionals work in pseudocode
IF distance < 4
hero sneakRight
ELSE
hero moveRight
hero jumpRight
IF distance < 4
hero sneakRight
IF distance > 4
hero moveRight
hero jumpRight
Concept Check: If/Else Conditionals
Let’s choose our own adventure using if/else conditionals!
hero enters cave
IF afraid of the dark
hero lightsTorch�ELSE
[action]
You enter a cave
IF you are afraid of the dark
TRUE
ELSE
TRUE
A bear shows up and chases you out of the cave!
You keep going and find a treasure chest.
ELSE
You light a torch
You call out “Hello?”
Nothing happens so you go deeper into the cave.
IF you start singing
If/Else Conditionals
Python
JavaScript
The syntax of if/else conditionals is quite similar to if/then conditionals. Remember where to use indentations and colons/braces!
if distance < 4:
hero sneakRight()
else:
hero moveRight()
hero jumpRight()
if (distance < 4){
hero sneakRight();
}else{
hero moveRight;
}
hero jumpRight;
Independent Practice
New Earth Spells
The two earth spells let you defeat enemies, whether they’re near or far.
enemy = findNearestEnemy
distance = getDistanceTo(enemy)
IF distance < 3
hero castEarthWave
hero sneakRight 2
ELSE
hero castEarthPit(enemy)
hero moveRight 1
Independent Practice
Play Ozaria
Start with Cinematic: Conditional Casting�and stop after you finish Cinematic: The Truth
Extension Activity: Design a Conditional Story
Use the link provided by your teacher to complete�This activity.
Need Help?�Always try it once & try using the troubleshooting guide first. If you still need help after that, then reach out to a classmate or the teacher.
Check-In
What did you discover?
Chapter 2, Module 4, Lesson 3
What I did:
-How far did you get in Ozaria? What was your favorite part?
What I noticed:
-What did you notice as you played through the game?
-Did you discover or learn something new?
What was challenging?�-Was something confusing about the story or the levels?
-Do you need more practice on a specific part of the code or the game?
Module 4, Lesson 4
Explorations
Computing Systems:
How Computing Systems Work
Recall the Acodus. How does the Acodus work?
�What are the different components of your computer?
What do each of these components do?
Computing Systems
Computing Systems
Recall the different parts of a computer system. Think about a chromebook.
Computer System Schematic
Input (includes sensors)
Output
Processor
Memory
Input -- keyboard, trackpad, microphone, video camera
Processor -- internal device which executes instructions
Memory -- internal device that stores information
Output -- visible elements displayed on the screen, audio sounds from the speakers
Computing Systems
Now let’s think about the Acodus. Can you identify the different components?
hero.moveLeft()
hero.moveUp()
hero.moveRight()
hero.use("door")
Computer System Schematic
Input (includes sensors)
Output
Processor
Memory
Humans vs Computers
How do humans and computers compare? What are some examples?
| Input | Processor | Memory | Output |
Human | | | | |
Computer | | | | |
Humans vs Computers
Let’s compare how humans and computers function.
| Input | Processor | Memory | Output |
Human | 5 primary senses (sight, hearing, touch, taste, & smell) | The human brain | Memory | Speech, writing, gestures, actions, reactions |
Computer | Devices like a keyboard, mouse, touchscreen, camera, & microphone | CPU | Storage devices like hard drives, solid-state drives, & memory chips | Screens & speakers |
Discuss
What kinds of tasks are humans best at?
-Why?
What kinds of tasks are computers best at?
-Why?
Humans + Computers
For some tasks, humans and computers need to work together.
We refer to really large datasets as Big Data.
These datasets present challenges when processing and drawing conclusions from so much data.
Big Data
Explore
Share
Let’s show the class what you discovered!
Resources
Standards Alignment & Additional Resources
CSTA Standards Alignment
Computing Systems
-1B-CS-01: Describe how internal and external parts of computing devices function to form a system.
-2-CS-03: Systematically identify and fix problems with computing devices and their components
Algorithms & Programming
-1A-AP-15: Using correct terminology, describe steps taken and choices made during the iterative process of program development.
-1B-AP-10: Create programs that include sequences, events, loops, and conditionals.
-1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.
-1B-AP-12: Modify, remix, or incorporate portions of an existing program into one's own work, to develop something new or add more advanced features.
-1B-AP-15: Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended.
-2-AP-10: Use flowcharts and/or pseudocode to address complex problems as algorithms.
-2-AP-13: Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
Common Core State Standards
Reading: Informational Text
-CCSS.ELA-LITERACY.RI.6.2: Determine a central idea of a text and how it is conveyed through particular details; provide a summary of the text distinct from personal opinions or judgments.
-CCSS.ELA-LITERACY.RI.6.7: Integrate information presented in different media or formats (e.g., visually, quantitatively) as well as in words to develop a coherent understanding of a topic or issue.
-CCSS.ELA-LITERACY.RI.6.10/CCSS.ELA-LITERACY.RI.7.10/: By the end of the year, read and comprehend literary nonfiction in the grades 6-8 text complexity band proficiently, with scaffolding as needed at the high end of the range.
-CCSS.ELA-LITERACY.RI.7.2/CCSS.ELA-LITERACY.RI.8.2: Determine two or more central ideas in a text and analyze their development over the course of the text; provide an objective summary of the text.
-CCSS.ELA-LITERACY.RI.7.3: Analyze the interactions between individuals, events, and ideas in a text (e.g., how ideas influence individuals or events, or how individuals influence ideas or events).
Writing
-CCSS.ELA-LITERACY.W.6.6: Use technology, including the Internet, to produce and publish writing as well as to interact and collaborate with others; demonstrate sufficient command of keyboarding skills to type a minimum of three pages in a single sitting.
-CCSS.ELA-LITERACY.W.6.7: Conduct short research projects to answer a question, drawing on several sources and refocusing the inquiry when appropriate.
Common Core State Standards
Writing (continued)
-CCSS.ELA-LITERACY.W.6.10/CCSS.ELA-LITERACY.W.7.10/CCSS.ELA-LITERACY.W.8.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.
-CCSS.ELA-LITERACY.W.7.4/CCSS.ELA-LITERACY.W.8.4: Produce clear and coherent writing in which the development, organization, and style are appropriate to task, purpose, and audience.
-CCSS.ELA-LITERACY.W.7.6: Use technology, including the Internet, to produce and publish writing and link to and cite sources as well as to interact and collaborate with others, including linking to and citing sources.
-CCSS.ELA-LITERACY.W.7.7: Conduct short research projects to answer a question, drawing on several sources and generating additional related, focused questions for further research and investigation.
-CCSS.ELA-LITERACY.W.7.8/CCSS.ELA-LITERACY.W.8.8: Gather relevant information from multiple print and digital sources, using search terms effectively; assess the credibility and accuracy of each source; and quote or paraphrase the data and conclusions of others while avoiding plagiarism and following a standard format for citation.
-CCSS.ELA-LITERACY.W.8.6: Use technology, including the Internet, to produce and publish writing and present the relationships between information and ideas efficiently as well as to interact and collaborate with others.
Speaking & Listening
-CCSS.ELA-LITERACY.SL.6.1/CCSS.ELA-LITERACY.SL.7.1/CCSS.ELA-LITERACY.SL.8.1: Engage effectively in a range of collaborative discussions (one-on-one, in groups, and teacher-led) with diverse partners on grade 6-8 topics, texts, and issues, building on others' ideas and expressing their own clearly.
Common Core State Standards
Speaking & Listening (continued)
-CCSS.ELA-LITERACY.SL.6.4: Present claims and findings, sequencing ideas logically and using pertinent descriptions, facts, and details to accentuate main ideas or themes; use appropriate eye contact, adequate volume, and clear pronunciation.
-CCSS.ELA-LITERACY.SL.6.6/CCSS.ELA-LITERACY.SL.7.6/CCSS.ELA-LITERACY.SL.8.6: Adapt speech to a variety of contexts and tasks, demonstrating command of formal English when indicated or appropriate.
-CCSS.ELA-LITERACY.SL.7.4/CCSS.ELA-LITERACY.SL.8.4/: Present claims and findings, emphasizing salient points in a focused, coherent manner with pertinent descriptions, facts, details, and examples; use appropriate eye contact, adequate volume, and clear pronunciation.
Common Core State Standards
Math: Expressions & Equations
-CCSS.MATH.CONTENT.6.EE.B.6: Use variables to represent numbers and write expressions when solving a real-world or mathematical problem; understand that a variable can represent an unknown number, or, depending on the purpose at hand, any number in a specified set.
-CCSS.MATH.CONTENT.6.EE.B.8: Write an inequality of the form x > c or x < c to represent a constraint or condition in a real-world or mathematical problem. Recognize that inequalities of the form x > c or x < c have infinitely many solutions; represent solutions of such inequalities on number line diagrams.
-CCSS.MATH.CONTENT.7.EE.B.4: Use variables to represent quantities in a real-world or mathematical problem, and construct simple equations and inequalities to solve problems by reasoning about the quantities.
Resource Links
Teacher Materials
-Chapter 2 Solution Guide - Python
-Chapter 2 Solution Guide - JavaScript
Student Materials�-Check-in Journal Template
-Lesson 1 Extension Activity - Design a Map
-Lesson 2 Extension Activity - Conditional Card Game
-Lesson 3 Extension Activity - Conditional Story
-Explorations Research Links
-An introductory robot programming tutorial