Complex Conditionals
Summary
Materials
- Day 5 PowerPoint deck
- Hungry
- Hungry Mod (for teacher)
- NOT Left (for teacher)
- Quadrants (for teacher)
- Boolean Statements and Expressions handout
- Boolean Statements and Expressions handout in Word
- Activity: Boolean Statements and Expressions
Reference
Instructional Activities and Classroom Assessments
- Boolean Refresher (5 minutes)
- Using Booleans (20 minutes)
- Boolean Practice (25 minutes)
- Reflection/Homework
Learning Objectives
- AAP-2.E For relationships between two variables, expressions, or values:
- a. Write expressions using relational operators. 2.B
- b. Evaluate expressions that use relation operators. 4.B
- AAP-2.F For relationships between Boolean values:
- a. Write expressions using logical operators.β2.B
- b. Evaluate expressions that use logic operators.β4.B
- AAP-2.H For selection:
- a. Write conditional statements.β2.B
- b. Determine the result of conditional statements.β 4.B
- AAP-2.I For nested selection:
- a. Write nested conditional statements.β2.B
- b. Determine the result of nested conditional statements.β4.B
Essential Knowledge
AAP-2.E.1 A Boolean value is either true or false.
AAP-2.E.2 The exam reference sheet provides the following relational operators: =, β , >, <, β₯, and β€. Text and Block:
Β§ a = b
Β§ a β b
Β§ a > b
Β§ a < b
Β§ a β₯ b
Β§ a β€ b
These are used to test the relationship between two variables, expressions, or values. A comparison using a relational operator evaluates to a Boolean value. For example, a = b evaluates to true if a and b are equal; otherwise, it evaluates to false.AAP-2.F.1 The exam reference sheet provides the logical operators NOT, AND, and OR, which evaluate to a Boolean value.
AAP-2.F.2 The exam reference sheet provides Text: NOT condition Block: NOT condition which evaluates to true if condition is false; otherwise it evaluates to false.
AAP-2.F.3 The exam reference sheet provides Text: condition1 AND condition2 Block: condition1 AND condition2 which evaluates to true if both condition1 and condition2 are true; otherwise it evaluates to false.
AAP-2.F.4 The exam reference sheet provides Text: condition1 OR condition2 Block: condition1 OR condition2 which evaluates to true if condition1 is true or if condition2 is true or if both condition1 and condition2 are true; otherwise it evaluates to false.
AAP-2.F.5 The operand for a logical operator is either a Boolean expression or a single Boolean value.
AAP-2.H.1 Conditional statements, or "if-statements," affect the sequential flow of control by executing different statements based on the value of a Boolean expression.
AAP-2.H.2 The exam reference sheet provides
- Text: IF(condition) { <block of statements> }
- Block: IF condition block of statements in which the code in block of statements is executed if the Boolean expression condition evaluates to true; no action is taken if condition evaluates to false.
AAP-2.I.1 Nested conditional statements consist of conditional statements within conditional statements.
Details
1. Booleans refresher (5 minutes)
- Remind students what Boolean logic and Boolean variables are.
- Explain Boolean flags.
2. Using Boolean (20 minutes)
- Students will further how to incorporate Boolean flags in their programs.
- Students will evaluate code segments and modify them to use Boolean logic:
- Students will work independently to modify the areYouHungry code segment to improve its functionality.
- Students will work with a partner to use the NOT variable to move a sprite with the controllers and have the sprite say something.
- Encourage students to publish their projects and add the links.
- Guide students how to use:
- Not
- And
- Or
- Nested conditionals
3. Boolean practice (25 minutes)
- Go to Boolean Statements and Expressions.
- Task students with completing Tasks 3 and 4.
- If students have time, encourage them to complete the extensions activities.
4. Reflection/Homework
If you run out of time, you may also assign this as individual homework. Students should complete their reflection.
What is a Boolean flag? Describe a case in which you might you want to use one?
What is the difference between an AND block and an OR block?
- In what cases will they both evaluate to true?
- In what cases will they both evaluate to false?
- In what cases will they evaluate differently?