Boolean#

The Switch Boolean block is used to return a condition as either True or False. These conditions are defined with Switch Python functions.

They are shaped to fit inside any blocks with hexagonal (six-sided) inputs.

boolean_block

Select the open space of the block indicated in the image here and begin typing.

boolean_select

Switch Boolean blocks can be used for single lines of Switch Python functions that directly will report a true or false condition.

Operators can be used to evaluate multiple Switch Python functions in a single Switch Boolean block. This includes:

  • and

  • or

  • not

boolean_operator

A Switch Boolean block can also combine Switch Python functions with comparison operators to evaluate how a value reported compares to the given number using the following operators:

  • Greater Than: >

  • Less Than: <

  • Equal to: =

  • Additional operators that can be used include <=, !=, and >=

boolean_comparison

In order for a Switch Boolean block to function as intended, the Switch Python commands must be entered with the correct spelling, punctuation, and indentation. Refer to the Help of each block to see the matching Switch Python command.

In this example, the code will check continuously if the Left Bumper Sensor was pressed. If the sensor is pressed, it will print “Bumper was pressed!” to the Print Console.

boolean_example