Close
Close full mode
logoMakeCode AP CSP

Complex Conditionals

Summary

Materials

Reference

Instructional Activities and Classroom Assessments

  1. Boolean Refresher (5 minutes)
  2. Using Booleans (20 minutes)
  3. Boolean Practice (25 minutes)
  4. 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)

4. Reflection/Homework

If you run out of time, you may also assign this as individual homework. Students should complete their reflection.

  1. What is a Boolean flag? Describe a case in which you might you want to use one?

  2. 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?
πŸ“˜ Unit 5 - AAP Part 2 β€” Previous
Day 5
Next β€” πŸ“˜ Unit 5 - AAP Part 2
Boolean Statements and Expressions