Close
Close full mode
logoMakeCode AP CSP

Boolean Variables

Summary

Materials

Instructional Activities and Classroom Assessments

  1. Recap Strings (5 minutes)
  2. Introduce Boolean Variables (10 minutes)
  3. Coding with Boolean Logic Operators (15 minutes)
  4. Introduce Relational Operators (5 minutes)
  5. Coding with Relational Operators (15 minutes)
  6. Homework

Learning Objectives

  • CRD-2.B Explain how a program or code segment functions. 4.A
  • CRD-2.G Describe the purpose of a code segment or program by writing documentation. 4.A
  • AAP-1.A Represent a value with a variable. 3.A
  • AAP-2.E For relationships between two variables, expressions, or values:
    • Write expressions using relational operators. 2.B
    • Evaluate expressions that use relational operators. 4.B
  • AAP-2.F

Essential Knowledge

  • CRD-2.A.1 The purpose of computing innovations is to solve problems or to pursue interests through creative expression.
  • CRD-2.B.2 A code segment is a collection of program statements that is part of a program.
  • CRD-2.G.3 Programmers should document a program throughout its development.
  • AAP-1.A.1 A variable is an abstraction inside a program that can hold a value. Each variable has associated data storage that represents one value at a time, but that value can be a list or other collection that in turn contains multiple values.
  • AAP-1.A.2 Using meaningful variable names helps with the readability of program code and understanding of what values are represented by the variables.
  • AAP-2.E.1 A Boolean value is either true or false.
  • AAP-2.E.2
  • AAP-2.F.1
  • AAP-2.F.2
  • AAP-2.F.3
  • AAP-2.F.4
  • AAP-2.F.5

Details

1. Variables/Strings recap (5 minutes)

  • What is a variable? A variable is an abstraction insider a program that can hold a value.
  • What types of variables are there? Sprite, integers, sStrings, Boolean, and lists.
  • How do you name a variable? Any way you like, but make it meaningful so you know what it is later.
  • What is a string? text
  • How do designate a string variable? Surround it with quotes.
  • What is the fancy word for join? Concatenate
  • What can be joined? Strings can be joined with integers when helped with a join block.
  • Can a string variable change? Yes! It can be changed as an event occurs or with user input.

2. Introduce Boolean variables (10 minutes)

  • Discuss the difference between how humans make decisions compared to how computers make decisions.
  • Define Boolean variables.
  • Discuss Booleans in everyday life.
  • Evaluate Boolean variable within the "Sleepy" code segment.
  • Discuss Boolean logic operators in MakeCode Arcade.
  • Task students with completing the exercises on the Boolean Operator Practice page.
  • Discuss Boolean logic operators on the Exam Reference Sheet.

3. Coding with Boolean Logic Operators (15 minutes)

  • Task students with:
    • Create a code segment that includes a conditional statement based on something they experience.
    • Examples include:
      • Having money to eat with friends.
      • Studying for a test.
      • Preparing for a concert, play, game, or meet
    • Students will create a variable related to the activity.
    • Set it to either true or false.
    • Create an event that happens if the variable is true.
  • When they are finished:
    • Have students save their code to their computer.
    • Ask students to share their code and post the link to it on the My Code Segments for Boolean Activities page.
    • Depending on your class collaboration system, you can have students copy and paste their program links in an email, LMS system, Class OneNote, or other tool.

4. Introduce Relational Operators (5 minutes)

  • Discuss what relational operators are.
  • Discuss relational operators or comparison statements in MakeCode Arcade.
  • Discuss relational operators on the Exam Reference Sheet.
  • Evaluate relational operators within the "Drive or Bike" code segment.

5. Coding with Relational Operators (15 minutes)

  • Task students with:
    • Create a code segment that includes a relational operator.
    • Examples include:
      • Voting age
      • Discount at the movies for specific age
    • Students will create a variable for the qualifying event.
    • Determine which relational operator they will use.
    • Determine what will happen when that relational operator is true (or false).
  • When they are finished:
    • Have students save their code to their computer.
    • Ask students to share their code and post the link to it on the My Code Segments for Boolean Activities page.
    • Depending on your class collaboration system, you can have students copy and paste their program links in an email, LMS system, Class OneNote, or other tool.

6. Homework

(Students should complete their reflection in their OneNote.)

  • How does using Boolean variables affect how your code is written?
πŸ“˜ Unit 3 - AAP Part 1 β€” Previous
Day 11
Next β€” πŸ“˜ Unit 3 - AAP Part 1
Boolean Operator Practice