Category:Logic

Allows you to check if two different conditions are true or false at the same time.

Commonly used to construct complex if statements.

And: Returns true if both conditions are true.

Or: Returns true if at least one condition is true.

Examples

Example 1

These animals want to swap size. Press the spacebar to help them determine if they succeeded. (The code checks to see if the cow and the hippo are their desired sizes.)

Example 2

This program checks if the pink alien or the yellow alien can guess the same number as the green alien. If either one gets it right, they celebrate. Press “g” to make them guess.

Parameters

NameDescription
condition 1 A sequence of blocks, including logic blocks, that the computer can evaluate as either true or false
operation and/or
condition 2 A sequence of blocks, including logic blocks, that the computer can evaluate as either true or false

Tips

  • Use “and” if multiple conditions have to be true for the code to run. Use “or” if only one of several conditions has to be true for the code to run.

Found a bug in the documentation? Let us know at documentation@code.org