How to program in Scratch, using Boolean logic
- Boolean operators include:
- AND, OR, NOT, < , = , >
- In other words, is one sprite touching some other thing? The answer by definition must be true or false.
- In other words, is one sprite touching something of a certain color? The answer by definition must be true or false.
- In other words, is a certain key being pressed?
- In other words, is the mouse being used?
- Why use Boolean operators?
- To focus a search, particularly when your topic contains multiple search terms.
- To connect various pieces of information to find exactly what you’re looking for.
A Boolean block is a hexagonal block (shaped after the Boolean elements in flowcharts)
The block contains a condition. The answer to the condition will be either true or false.
It’s important to determine if a statement (expression) is “true” or “false”.
Ways to determine TRUE and FALSE are prevalent in all kinds of decision making.
A mathematically precise way of asking if something is TRUE or FALSE is called a Boolean operation.
It is named after George Boole, who first defined an algebraic system of logic in the mid 19th century.
Boolean data is associated with conditional statements. For example, the following statement is really
a set of questions that can be answered as TRUE or FALSE.
IF (I want to go to a movie) AND (I have more than $10) THEN (I can go to the movie)
We can combine several “boolean” statements that have true/false meaning into a single statement
using words like AND and OR, and NOT).
“If I want to go to the movie AND I have enough money, then I will go to the movie.”
BOTH conditions have to evaluate to true (have to be true) before the entire expression is true.
Some terms you already learned in math are really Boolean operators
Less than < [ ] < [ ] > Equal to < [ ] = [ ] > Greater than < [ ] < [ ] >
For example: (The height of a building) < 20 meters
For any building we look at, this statement will either be true or false.
Go through what each Boolean block does (page 68)
Book “Adventures in Coding”, Eva Holland and Chris Minnick, Wiley, 2016. Pages 50-59
Computational Thinking 6-8.CT.c.2 Describe how computers store, manipulate, and transfer data types and files (e.g., integers, real numbers, Boolean Operators) in a binary system.
CSTA K-12 Computer Science Standards
CT.L2-14 Examine connections between elements of mathematics and computer science
including binary numbers, logic, sets and functions.
CPP.L2-05 Implement problem solutions using a programming language, including: looping behavior, conditional statements, logic, expressions, variables, and functions.