This course is part of Coding/STEAM Curriculum - Middle School Plan

Middle School Plan
$2,600 per year

Python 201

A deeper look at Python for intermediate or advanced coders in upper middle or high school with a focus on real-world computing problems. Request Quote

Course Summary
  • Grades 8+
  • Advanced level
  • 15 lessons
  • Python
    • Web
Course Includes
  • 15 lessons
  • 129 activities
  • Enhanced Creativity Tools
  • Automatic Assessment
  • Tutorials and Reviews
  • Coding Puzzles
  • DIY Projects
  • Quizzes
  • Answer Keys
Prerequisites
No previous coding experience required.

Lesson Plan

Lesson: Boolean Logic

Time: 40+ mins

Introduction

In this lesson, students will learn about a boolean, which is a data type that has only two possible values: True or False. Students will also combine a mix of booleans, variables, and operators as they solve puzzles in the modules.

Vocabulary

  • Logic/Boolean Expressions: A logic expression is an expression that calculates a boolean value using a mix of booleans, variables, and operators.
  • Boolean: A value that is either True or False. In Python, True and False must be capitalized. Python equates True to the number 1, and False to the number 0. An empty string is considered False.
  • "Equality" Operator: The "equality" operator (==) will produce a boolean value based on whether or not the left side is equal to the right side of an expression.
  • "Not Equal" Operator: The "not equal" operator (!=) will produce a boolean value based on whether or not the left side is not equal to the right side of an expression.
  • "is" Operator: The "is" operator produces True if the values on either side of the operator refer to the same value, usually referring to the same value in a computer's memory. Note: The == operator compares the values, while "is" compares the memory locations.
  • "is not" Operator: The "is not" operator produces True if the values on either side of the operator do not refer to the same value in the computer’s memory.
  • "and" Operator: The "and" operator will only produce True if the values on the left and right are both True. The "and" operator is commonly used to combine multiple mathematical comparisons (e.g, x>1 and x<10). If both the "and" and "or" operators are used in an expression, the "and" operator is evaluated first.
  • "or" Operator: The "or" operator will produce True if one or both or the values in the expression is true. If both the "and" and "or" operators are used in an expression, the and operator is evaluated first.
  • "not" Operator: The "not" operator is not a binary operator and only takes one value. The not operator will evaluate to True if the number to the right of the operator is False and vice versa.

Objectives

Students will...
  • Write and apply logic/boolean expressions
  • Use boolean operators to compare values and expressions
  • Predict the results of comparisons using math or the ASCII table

Materials

  • Computers (1 per student) with student account access to Tynker.com

Warm-Up (5 minutes)

Ask students to answer these short-response questions:
  • Draw a face that expresses how you feel about the Python 201 course so far. What are some questions,concerns, or doubts you or someone you know has about using Python?
  • What do you do if you notice your code isn’t working as expected, but you don’t know how to fix it?
  • What is the difference between the == operator and the "is" operator? (The == operator compares the values, while "is" compares the memory locations)
  • What is the difference between the != operator and the "is not" operator? (The != operator compared the values, while "is not" compares the memory locations)

Activities (35 minutes)

Facilitate as students complete the Boolean Logic modules on their own:
1. Logic (Tutorial)
    • In this module, students are introduced to boolean logic.
    • Emphasize that in Python, “true” and “false” are capitalized.
    • Are students struggling with the “Gymnastics score” puzzle? Give a hint: Tell students that for each gymnastics move, they will need to multiply the total number of points from the move (e.g., “handspring * 2).
2. Equality Operators (Tutorial)
    • In this module, students will learn about equality operators.
    • Optional: Before students select the “play” button in the examples, ask them to write down whether they think the code will output to True or False.
    • Optional: Ask students, “True or false: The ‘==’ operator and the ‘is’ operator are the same.” (False)
3. Inequalities (Tutorial)
    • In this module, students are introduced to inequalities.
    • Encourage students to create and test their own examples of inequalities. Here’s an example: print( 15 <= 10 )
    • Are student struggling with the “Valid triangle” puzzle? Give a hint: Tell students that the sum of any two sides of a triangle must be greater than the length of the third side.
4. Comparing Strings (Tutorial)
    • In this module, students will learn how the equality and inequality operators can be used on strings.
    • Students will need to solve 3 puzzles. If they’re struggling, direct their attention to the hints and encourage students to brainstorm possible solutions with a partner.
5. And Operator (Tutorial)
    • Students are introduced to the “and” operator, which produces “True” if the values on the right and left are both “True.”
    • Are students struggling with the “Even two digit number” puzzle? Give a hint: Tell students that the number “n” must be an even number. Their code for this condition might look like this: n % 2 == 0
6. Or Operator (Tutorial)
    • Students are introduced to the “or” operator, which produces “True” if one or both boolean values are “True.”
    • Optional: Before students select the “play” button in the examples, ask them to write down what they think the code will output.
    • Are students struggling with the “Even with two or odd with three” puzzle? Give a hint: Tell students to use the modulus operator (%).
7. Not Operator (Tutorial)
    • Students are introduced to the “not” operator, which produces “True” if the value on the right is equivalent to “False,” and “True” otherwise.
    • Are students struggling with the “Happy or not” puzzle? Give a hint: Tell students to replace the “?” in the following code: print(? and not ? and ?)
    • Are students struggling with the other puzzles? Direct their attention to the “hint” button and encourage them to brainstorm possible solutions with a neighbor.
8. Quiz
    • In this quiz, students will answer 6 boolean logic problems.
    • In each problem, students will need to apply boolean logic with coding concepts learned in previous lessons.

Discussion Questions/Follow-Up Activities (20 minutes)

Logic Gates
Ask students to apply boolean logic and fill in the following logic gates:


Answers:

US Standards

  • CCSS-ELA: SL.8.1, RI.9-10.3, RI.9-10.6, RI.11-12.3, RI.11-12.6, L.9-10.3, L.9-10.6, L.11-12.3, L.11-12.6
  • CCSS-Math: HSN.Q.A.1, HSN.Q.A.2, HSN.Q.A.3, MP.1, MP.2, MP.4
  • CSTA: 2-AP-11, 2-AP-13, 2-AP-17, 3A-AP-17, 3B-AP-11
  • CS CA: 6-8.AP.11, 6-8.AP.13, 6-8.AP.17, 9-12.AP.12, 9-12.AP.16
  • ISTE: 1.c, 1.d, 4.d, 5.c, 5.d