← Back to course
1/6
Week 03 · Making Decisions

Monday

Questions with two answers
// Booleans, conditions and alert rules
⏱ about 20 min

Monday: Questions With Two Answers

Beacon's Plant Status screen works. Every row shows its water level, and Lena loves it.

Comet is already restless. "Now Beacon should warn us when the tomatoes need water. Easy. Just warn when it is low."

Wren points at two readings on the screen. "What do you notice? Row 2 says 25. Row 5 says 60. Which one is low?"

"Row 2, obviously," Comet says. "But how does Beacon know that?"

Nova hovers between the numbers. "Would you like a hint?" she asks. "Every warning starts with a question that has only two possible answers."

Comet thinks. "Is the water level less than 30? Yes or no."

Wren smiles. "True or false," he corrects.

Boolean values

A Boolean value is either true or false. There is no third choice.

A comparison using a relational operator evaluates to a Boolean value.

So "Is the water level less than 30?" is a comparison, and its answer is true or false.

Beacon's alerts will all be built from comparisons like this one.

Relational operators

Relational operators compare two values. The table shows how each one is written in our pseudocode and how to read it aloud.

PseudocodeRead it aloud as
waterLevel = 30water level is equal to 30
waterLevel ≠ 30water level is not equal to 30
waterLevel > 30water level is greater than 30
waterLevel < 30water level is less than 30
waterLevel ≥ 30water level is at least 30
waterLevel ≤ 30water level is at most 30

Suppose waterLevel holds 25 and lightLevel holds 80. Use these four conditions for the next questions.

C1:  waterLevel < 30
C2:  waterLevel ≥ 30
C3:  lightLevel = 80
C4:  lightLevel > 80
TRUE OR FALSE?
  • Read the question.
  • Tap your answer.
C1: water level is less than 30. True or false?
C2: water level is at least 30. True or false?
C3: light level is equal to 80. True or false?
C4: light level is greater than 80. True or false?
WHICH READING MAKES THE CONDITION TRUE?
  • Read the question.
  • Tap your answer.
Condition: water level is at most 40. Which reading makes it true?
Condition: water level is greater than 70. Which reading makes it true?
Condition: light level is not equal to 50. Which reading makes it false?
StatementTrue or false?
A Boolean value is either true or false.?
A comparison evaluates to a Boolean value.?
Is at least 30 is true when the reading is exactly 30.?
Is greater than 30 is true when the reading is exactly 30.?
A Boolean can also be maybe.?
WHY THIS EXERCISEThe edge value, exactly 30, is where many alert rules go wrong.
A value that is either true or false is a ____ value.
A symbol that compares two values is a ____ operator.
Try it
Listen for yes-or-no questions people ask today, such as "Is it raining?"
Write three of them as comparisons, like temperatureOutside < 10, and decide if each is true right now.
On paper, draw a number line from 0 to 100. Shade every water level that makes "water level is less than 30" true, and mark the edge at 30.

Strong start, developer. Tomorrow Beacon starts making real decisions with IF.