# Logical Operators

Logical operators are used to combine tests. Instead of embedded or multiple statements, one if statement could handle it all.

For most languages except Python:

|                                     | Operator | Example(s)                            |
| ----------------------------------- | -------- | ------------------------------------- |
| and (all tests are true)            | `&&`     | `if (x > 1 && x < 5) { ... }`         |
| or (at least one test is true)      | `\|\|`   | `if (num == 3 \|\| num == 6) { ... }` |
| not (runs if the variable is false) | `!`      | `if (!lightOn) { ... }`               |

Python:

{% hint style="warning" %}
These examples have not been tested.
{% endhint %}

|                                     | Operator | Example(s)                     |
| ----------------------------------- | -------- | ------------------------------ |
| and (all tests are true)            | `and`    | `if x > 1 and x < 5: ...`      |
| or (at least one test is true)      | `or`     | `if num == 3 or num == 6: ...` |
| not (runs if the variable is false) | `not`    | `if not lightOn: ...`          |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hopemoore.gitbook.io/coding-for-creatives-spring-2021/glossary-and-terms/operators/logical-operators.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
