# 3. Logic¶

## 3.1. When to Use Logic Commands¶

Logic Commands can only be used within a Control Flow Statement. Logic Commands allow a Control Flow Statement to check if a condition is met or how values relate to one another.

## 3.2. Relational Operator¶

The Relational Command uses a relational operator to test the relationship between two numbers, variables, parameters, or mathematical expressions. This relation can return either true or false. You can choose from these relational operators:

• == Equal to
• != Not equal
• > Greater than
• < Less than
• >= Greater than or equal to
• <= Less than or equal to

## 3.3. Logical Operators¶

Binary Operators Logical Conjunction(AND)

The logical conjunction, AND, returns true only if both of it’s conditions are true. This can be represented with a truth table: Logical Disjunction(OR)

The logical disjunction, OR, returns true if one or both of it’s conditions are true. This can be represented with a truth table: The NOT logical operator is used to check if a condition is not true. When a condition preceded by a NOT is false, it returns true.

The following checks to see if the My Name Variable is not equal to “Mike”. If this condition is true, the Score Variable will be set to -1. ## 3.4. Testing a Key¶

We have the Key Down/Key Up events to check whether any key is pressed or released. You can use an If Statement along with a Key Command to check if a specific key is touched. You can even use an AND Operator to check if two keys are being pressed. You can use the Key Command inside of any event.