• Sometimes we want to ask questions about data. For example, is x greater than y? Is one string equal to another? These questions can’t be answered with Numbers. Instead, they are answered with a new data type called a Boolean.

  • video games use Booleans for many things: asking when a player’s health is equal to zero, whether two characters are close enough to bump into one another, or if a character’s coordinates put it off the edge of the screen.

  • A Boolean value is either true or false. Unlike Numbers, Strings, and Images, Booleans have only two possible values.

  • You already know some functions that produce Booleans, such as < and >! Our programming language has them, too: (< 3 4), (> 10 2), and (= -10 19).

  • We also have ways of writing Compound Inequalities, so we can ask more complicated questions using the and and or functions.

    • (and (> 3 4) (< 10 2)) translates to "three is greater than four and ten is less than two". This will evaluate to false, since the and function requires that both sub-expressions be true.

    • (or (> 3 4) (< 10 2)), which translates to "three is greater than four or ten is less than two". This will evaluate to true, since the or function only requires that one sub-expression be true.

  • The Circles of Evaluation work the same way with Booleans that they do with Numbers, Strings and Images:

    and
    >
    34
    <
    102
    (and (> 3 4) (< 10 2))
    or
    >
    34
    <
    102
    (or (> 3 4) (< 10 2))

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). CCbadge Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.