
I want to rewrite this page to bring back a simplified version of my number guessing game with more predicates. They'll build these same predicates but for the context (e.g. project) of letting the player ask more than just greater/less than. (If not this, then I think we should start keep earlier on the page.) --MF
**ST-Some issues with the Guessing Game: "say" blocks need to be in an "if else" and "goto front" must be employed to avoid overlaps.**
Is this idea still relevant? --MF, 11/19/17
In this lab, you will develop a word puzzle solver that will search through a long list of words and report words with specific characteristics.
On this page, you will review predicates and build a few that you can use in other projects.
Predicates are reporter blocks (functions) that always report a Boolean value (they report only the values
or
). In Snap!, they are represented by hexagonal blocks.
You have seen predicates before. Predicates compute the condition used by conditionals (such as if or repeat until) to decide when to do something. Predicates ask a question such as "Does the player list contain the player's answer?" or "Is this sprite touching the sprite called 'Sprite'?"

block, which you can find in the Sensing palette.
You may find one or more of these Boolean operators helpful for between?.
You can decide whether between? will include the two boundary numbers or not. And you can change it later depending on where you use it.
block to report the result of reporter functions (including predicate functions).Many languages (and the AP CS Principles Exam) use return instead of report as the name of the command to give a value back at the end of a function call.
between? to create a script that lets you write on the stage in three colors (depending on the height on the stage), using your mouse:
mod block.
The
block reports the remainder when the first input is divided by the second. For example,
reports 2 because when 17 is divided by 5, the remainder is 2. When one number divides another evenly, the remainder is 0. So,
reports 0.
predicate using mod.divisible predicate to build a predicate that tests whether its input is even (divisible by 2).
even? block to draw a brick wall.
useful.
?


true if num is less than or equal to 23.


IF (MISSING CONDITION)
{
DISPLAY "This number is odd."
}

mod block reports the remainder when the first input is divided by the second. Whether a number is odd or even depends on divisibility by 2.

mod block reports the remainder when the first input is divided by the second. Whether a number is odd or even depends on divisibility by 2.

