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.

Switch Boolean block image used for defining True/False conditions in Switch Python functions with hexagonal inputs.

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

Illustration of a Switch Boolean block used to evaluate conditions in Python, showing hexagonal input space for commands.

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

Diagram showing a Switch Boolean block with hexagonal inputs for evaluating conditions in Python functions.

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 >=

Illustration of a Switch Boolean block used for True/False conditions in Python programming with hexagonal inputs.

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.

Diagram of a Switch Boolean block in Python, illustrating true/false conditions with hexagonal input shapes.